Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Undefined reference to WinMain in Cygwin

Tags:

cygwin

winmain

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.

like image 627
Fawad Nasim Avatar asked May 28 '14 17:05

Fawad Nasim


Video Answer


1 Answers

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

like image 88
Paul Avatar answered Oct 04 '22 01:10

Paul