I installed eclipse, cdt and mingw on my windows XP machine. added C:\MinGW\bin
to my PATH.
Created a new c++ project, with one file in it, test.c. the code in it开发者_运维技巧:
int main(){
int i=1;
}
Trying to build, I get the error:
/mingw/lib/libmingw32.a(main.o):main.c:(.text+0xd2): undefined reference to 'WinMain@16'
Notice it's not complaining about test.c
but rather about some main.c
in one of mingw's libs.
What am I doing wrong?
You need to save the .c
file first.
well, the solution was really weird, but I guess it would make sense to someone more proficient with CDT than me - My main() was inside a .c file. When I changed the suffix to be .cpp, it worked like a charm.
main.o from libmingw32.a should not be searched by the linker because the undefined symbol _main from crt2.o is (should be) satisfied by the "int main()" which you wrote.
Please copy & paste the gcc command lines that cdt is executing.
精彩评论