Undefined link to WinMain in Cygwin

I am trying to compile and have the 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 before, but now I think there might be some kind of cygwin settings or so ... m compiles into windows 8 on cygwin.

+8
cygwin winmain
source share
1 answer

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

+9
source share

All Articles