This is the mail archive of the
mailing list for the Cygwin project.
Re: Linking with .LIB files
- To: jqb at netcom dot com
- Subject: Re: Linking with .LIB files
- From: David W Palmer <David_W_Palmer at ccm dot jf dot intel dot com>
- Date: Mon, 31 Mar 97 12:10:00 PST
- cc: gnu-win32 at cygnus dot com, colin at bird dot fu dot is dot saga-u dot ac dot jp
Okay, the 'ol linking problem.
I tried declaring the following in simple.c:
void (*__CTOR_LIST__)(void) = 0;
void (*__DTOR_LIST__)(void) = 0;
char _data_start__, _data_end__, _bss_start__, _bss_end__;
It compiled! But would exit immediately when ran.
"gdb simple.exe" faulted, dumped the stack, and exited before running the
So, I tried the next suggestion: since the sample doesn't use any cygwin
functions, use MS libraries instead. This worked to the extent of linking.
Simple.exe again exits immediately after running.
"gdb simple.exe" shows that it runs, but gets a 0 from CreateWindow(). So,
I compared this behavior against what cl.exe does. Here's as far as I've
case 1: compile using
gcc -c simple.c -o simple.o -DWIN32 -D_DEBUG -D_WINDOWS
case 2: compile using
cl /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /c simple.c
mv simple.obj simple.o
In both cases, link using:
link /NOD simple.o libc.lib kernel32.lib user32.lib gdi32.lib
winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib
uuid.lib odbc32.lib odbccp32.lib opengl32.lib glu32.lib /nologo
/subsystem:windows /debug /machine:I386 /out:"Simple.exe"
I removed the "\"s for formatting reasons in this e-mail. And yes, I know
I don't need the majority of those .lib's - I just grabbed it from a
working simple.mak generated by VC 5.0.
Both methods generate a simple.exe that will run. However, case 2
successfully creates a window and the program runs fine. Case 1 gets a 0
return code from CreateWindow(). (sigh)
BTW, the GNU-Win32 FAQ at
Can I mix objects compiled with msvc++ and gcc?
Yes, this supposedly works. The key seems to be using MS's LINK.EXE to do
the linking instead of GNU ld. There may be issues with constructor calls
for C++/Obj C.
I see no evidence that could possibly support this claim. Though I have
not tried all possible combinations, I'm inclined to believe that gcc and
link are incompatible as suggested by Wiljan. If this is not the case, I'd
appreciate seeing a sample that works. Regardless, the FAQ should be
Text item: External Message Header
The following mail header is for administrative use
and may be ignored unless there are problems.
***IF THERE ARE PROBLEMS SAVE THESE HEADERS***.
Content-Type: text/plain; charset=us-ascii
References: <Thu, 27 Mar 97 12:33:08 PST_2@ccm.jf.intel.com>
Subject: Re: Linking with .LIB files
CC: email@example.com, firstname.lastname@example.org
To: David W Palmer <David_W_Palmer@ccm.jf.intel.com>
X-Mailer: Mozilla 3.01Gold (WinNT; I)
Organization: JQB Enterprises
From: Jim Balter <email@example.com>
Date: Thu, 27 Mar 1997 13:20:09 -0800
Received: from sba-ca1-24.ix.netcom.com(184.108.40.206) by dfw-ix10.ix.netcom.com
via smap (V1.3)
id sma006293; Thu Mar 27 15:23:33 1997
Received: (from smap@localhost)
by dfw-ix10.ix.netcom.com (8.8.4/8.8.4)
id PAA06304; Thu, 27 Mar 1997 15:23:58 -0600 (CST)
Received: from dfw-ix10.ix.netcom.com (dfw-ix10.ix.netcom.com [220.127.116.11]) b
y mailbag.jf.intel.com (8.8.5/8.7.3) with ESMTP id NAA20601 for <David_W_Palmer@
ccm.jf.intel.com>; Thu, 27 Mar 1997 13:32:57 -0800 (PST)
Received: from mailbag.jf.intel.com (mailbag.jf.intel.com [18.104.22.168]) by re
lay.jf.intel.com (8.7.6/8.7.3) with ESMTP id NAA24313 for <David_W_Palmer@ccm.jf
.intel.com>; Thu, 27 Mar 1997 13:30:39 -0800 (PST)
For help on using this list, send a message to
"firstname.lastname@example.org" with one line of text: "help".