views:

35

answers:

2

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?

A: 

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.

Adam Mitz
A: 

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.

noam
Perhaps since you created a "C++ Project" CDT did not consider the .c file part of it.
Adam Mitz