eclipse + cdt + mingw + windows error “undefined reference to `WinMain@16'” on build

不想你离开。 提交于 2019-12-13 05:30:02

问题


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?


回答1:


You need to save the .c file first.




回答2:


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.




回答3:


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.



来源:https://stackoverflow.com/questions/3269112/eclipse-cdt-mingw-windows-error-undefined-reference-to-winmain16-on-b

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!