Undefined reference to WinMain in Cygwin

瘦欲@ 提交于 2019-11-27 07:42:42

问题


I am trying to compile and having following problem

$ gcc errlib.c -o errlib.o

/usr/lib/gcc/x86_64-pc-cygwin/4.8.2/../../../../lib/libcygwin.a(libcmain.o): In function `main':
/usr/src/debug/cygwin-1.7.30-1/winsup/cygwin/lib/libcmain.c:39: undefined reference to `WinMain'
/usr/src/debug/cygwin-1.7.30-1/winsup/cygwin/lib/libcmain.c:39:(.text.startup+0x7e): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `WinMain'
collect2: error: ld returned 1 exit status

Any suggestions? These files are well tested and generated the code fine before but now i think there might be some cygwin settings or so ... m compiling on windows 8 on cygwin.


回答1:


Use -c compile flag to only produce object file. Without -c it tries to link an executable and the linker (called automatically) fails.



来源:https://stackoverflow.com/questions/23918318/undefined-reference-to-winmain-in-cygwin

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