Reputation: 129
Quick setup note:
I'm using Code::Blocks with GCC for compiling on Windows. I'm pretty new at this, but I'm just trying to compile the standard Hello World! program (since all my other programs were experiencing this). When I run the program I get the "Program.exe has stopped working" dialogue box. Here's the code:
#include <iostream>
using namespace std;
int main()
{
cout << "Hello world!" << endl;
return 0;
}
When I compile this I get no errors, however when I debug it, I get Cannot open file: ../mingwrt-4.0.3-1-mingw32-src/src/libcrt/crt/crt1.c after the program reaches the end of main.
Considering I can't fine any reference to that file path on my system, nor any .c file for crt1.c I'm thinking I need to adjust something somehwere, to reslove this. I just don't know where.
Upvotes: 0
Views: 414
Reputation: 26
I had exactly the same problem with mingw and Eclipse.
As you say, the project builds okay but does not run cleanly from within the IDE - experimenting I added the mingw/bin directory to my system path and then ran hello.exe from a Windows Command Prompt and it ran cleanly.
From within Eclipse run the project with menu option Run / Debug, the debugger steps code without problem until it exits main() and attempts to run the exit code within cstartup (otherwise located in crt1.c) then GDB/Eclipse complains and prompts for the missing file crt1.c.
I found the missing crt1.c file here, http://www.mingw.org/category/wiki/source_code (follow the link to the sourceforge repository and download the snapshot. I unpacked the whole thing and located it within the mingw32 folder).
In my case rerunning the project and adding the file when prompted and then rebuilding cleared the problem. I suspect there may be other ways to fix this but I don't know Eclipse and Mingw very well yet.
Hope this helps.
Eclipse Version: Indigo Service Release 2 Build id: 20120216-1857, mingw32-gcc-g++ 4.8.1, windows 8
Upvotes: 1