error: undefined reference to `_WinMain@16'

Joe Smith unknown_kev_cat@hotmail.com
Mon Oct 31 04:35:00 GMT 2005


"Fernando Barsoba" <fbarsoba@verizon.net> wrote in message 
news:436579B4.7020405@verizon.net...
> Hi,
>
> I'm trying to build a project with sha-1 and md5 implementations from 
> http://www.cr0.net:8040/code/crypto/sha1/      (in case it is important 
> information)
>
> and I'm getting the following error:
>
>
> **** Incremental build of configuration Debug for project Sha1 ****
>
> make -k all
> Building file: ../sha1.c
> Invoking: GCC C Compiler
> gcc -O0 -g3 -Wall -c -fmessage-length=0 -osha1.o ../sha1.c
> Finished building: ../sha1.c
>
> Building target: Sha1.exe
> Invoking: GCC C Linker
> gcc -oSha1.exe ./sha1.o
> /usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../libcygwin.a(libcmain.o)(.text+0xab): 
> undefined reference to `_WinMain@16'
> collect2: ld returned 1 exit status
> make: *** [Sha1.exe] Error 1
> make: Target `all' not remade because of errors.
> Build complete for project Sha1
>
> Any idea why is that? It's the first time is happening as far as I 
> remember..

Windows compilers actually rename the function called 'main'. I'm not sure 
what the reason is. The most obvious reason is that the code in the crt (c 
runtime) is run before main, but the actual entry point of the application 
(in the crt) is not named main. In Microsoft's crt it is named 
'WinMainCRTStartup' (or  'wWinMainCRTStartup' for unicode applications).

Cygwin uses the same renaming for consistancy (besides, I think it uses 
Microsoft's crt anyway.)


If you are compiling just the files you linked for the included stand alone 
test applicaton (that is the only thing sha1.exe could be)read this:
   The problem is that the code you referenced has no 'main' function. Look 
closely at the code and you will see
   you need to define 'TEST'.

Otherwise if you are trying to use it in a project of your own:
   You need to just include the files in the other project such that they 
are linked directly into the application. If you need
   more assistance you should contact somebody exepirenced with c, and with 
using Eclipse to compile c code. If they are at all
   confused regarding this error message just tell them that it is exactly 
equivelent to a message of
   "undefined reference to `_main'".

 



--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/



More information about the Cygwin mailing list