delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/03/03/14:06:57

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Subject: WinMain in an own static lib -> _WinMain AT 16 undefined reference ?! ;.(
From: "G.-B. Hauck" <gbhauck AT gmx DOT de>
To: cygwin AT cygwin DOT com
Message-Id: <1078340535.4312.9.camel@haux.local>
Mime-Version: 1.0
Date: Wed, 03 Mar 2004 20:02:15 +0100
X-LMT-BERLIN-MailScanner-Information: Please contact the ISP for more information
X-LMT-BERLIN-MailScanner: Found to be clean
X-IsSubscribed: yes

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 AT 16'
collect2: ld returned 1 exit status

Why ld can't find _WinMain AT 16 - nm -g libmaintest.a gives:
winmain.o:
         U _NewEntry
00000000 T _WinMain AT 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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019