From: jqb AT netcom DOT com (Jim Balter) Subject: Re: Linking with .LIB files 27 Mar 1997 02:25:44 -0800 Approved: cygnus DOT gnu-win32 AT cygnus DOT com Distribution: cygnus Message-ID: <333A33F0.4F58.cygnus.gnu-win32@netcom.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 3.01Gold (WinNT; I) Original-To: David W Palmer Original-CC: gnu-win32 AT cygnus DOT com, colin AT bird DOT fu DOT is DOT saga-u DOT ac DOT jp Original-Sender: owner-gnu-win32 AT cygnus DOT com David W Palmer wrote: > > Text item: > > For those who are watching: Colin Peter's text is left justified, mine is > indented. > > David W Palmer[SMTP:David_W_Palmer AT ccm DOT jf DOT intel DOT com] wrote: > > So, I have a simple program which uses OpenGL and I link with the > > following: > > > > link simple.o libuser32.a glu32.lib opengl32.lib libgdi32.a > > /subsystem:windows /machine:i386 > > LINK : error LNK2001: unresolved external symbol _WinMainCRTStartup > > simple.exe : fatal error LNK1120: 1 unresolved externals > > make: *** [simple.exe] Error 25 > > > > No .EXE is generated. And the answer is... what? Just what sort of thing is simple.o? If it is a POSIXish thing that has a main() and uses the POSIXish stuff provided by cygwin.dll then you need crt0.o and libcygwin.a and possibly others, and tell the linker that the entry point is _mainCRTStartup. If it's a win32ish thing then you should be providing your own _WinMainCRTStartup or tell the linker just what *is* your entry point. > This suggests to me that you need to include crt0.o in your link line > explicitly, since that's where _WinMainCRTStartup should be resolved. > Well, actually in the Cygnus sources it's not, but you could just add > a _WinMainCRTStartup entry point which calls the _mainCRTStartup > entry point and it should work OK I think. > > Yes, I thought of that too. > > //f/pgming/OpenGL/simple$ make > link simple.o crt0.o libuser32.a glu32.lib opengl32.lib libgdi32.a You still haven't told the linker what the entry point is or provided a _WinMainCRTStartup; read Colin's comments above again. > /subsystem:windows /machine:i386 > Microsoft (R) 32-Bit Incremental Linker Version 5.00.7022 > Copyright (C) Microsoft Corp 1992-1997. All rights reserved. > > crt0.o : error LNK2001: unresolved external symbol _cygwin_crt0 > LINK : error LNK2001: unresolved external symbol _WinMainCRTStartup > simple.exe : fatal error LNK1120: 2 unresolved externals > make: *** [simple.exe] Error 25 > //f/pgming/OpenGL/simple$ > > > So, I can trade WinMainCRTStartup() for cygwin_crt0(). No, now you are missing both. > Not much > progress. Though, this has to be defined somewhere! Which library? libcygwin.a. cygwin_crt0 calls dll_crt0 in cygwin.dll. > Unfortunately, I don't know how to list the functions in a library. nm for *.a > BTW: instead of defining WinMainCRTStartup(), it's easier to use the > link option /ENTRY:mainCRTStartup. But you didn't. You need to tell the linker your entry point or provide a _WinMainCRTStartup. -- - For help on using this list, send a message to "gnu-win32-request AT cygnus DOT com" with one line of text: "help".