This is the mail archive of the
cygwin
mailing list for the Cygwin project.
WinMain in an own static lib -> _WinMain@16 undefined reference ?! ;.(
- From: "G.-B. Hauck" <gbhauck at gmx dot de>
- To: cygwin at cygwin dot com
- Date: Wed, 03 Mar 2004 20:02:15 +0100
- Subject: WinMain in an own static lib -> _WinMain@16 undefined reference ?! ;.(
Hi Gurus !
I have a problem with cygwin gcc (gcc version 3.3.1 cygwin-special) - i
think that i just don't understand "ld" - so maybe someone can help me
....
For my "Application-Framework" i need to put WinMain(...) in a lib - but
it doesnt work - please take a look on a minimalistic example:
<snip--------------------------------------------------------/>
/* winmain.cc */
#include <windows.h>
extern "C" void NewEntry();
extern "C" int APIENTRY WinMain(HINSTANCE hI,HINSTANCE hPI,
LPSTR lpCmdLine,int nCmdShow)
{
NewEntry();
return 0;
}
<snip--------------------------------------------------------/>
/* test.cc */
#include <windows.h>
extern "C" void NewEntry()
{
MessageBox(NULL,"test","test",MB_OK);
}
------------
making test.exe with:
g++ -c winmain.cc
g++ -c test.cc
g++ -mwindows -mno-cygwin -o test.exe winmain.o test.o
is ok -> running test.exe gives you a wonderfull MessageBox ...
BUT:
g++ -c winmain.cc
g++ -c test.cc
ar -rs libmaintest.a winmain.o
g++ -mwindows -mno-cygwin -o test.exe test.o -L./ -lmaintest
/usr/lib/gcc-lib/i686-pc-mingw32/3.3.1/../../../../i686-pc-mingw32/lib/libmingw32.a(main.o)(.text+0x9b):main.c: undefined reference to `_WinMain@16'
collect2: ld returned 1 exit status
Why ld can't find _WinMain@16 - nm -g libmaintest.a gives:
winmain.o:
U _NewEntry
00000000 T _WinMain@16
Calling the linker with my lib "before" test.o, i.e.
g++ -mwindows -mno-cygwin -o test.exe -L./ -lmaintest test.o
gives the same ...
I'm hanging around for two days with this ;-(
TIA and Thank You, Spasibo, Danke, Merci ....
Georg
--
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/