Linking with .LIB files
David W Palmer
David_W_Palmer@ccm.jf.intel.com
Mon Mar 31 12:13:00 GMT 1997
Text item:
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
program. (ouch!)
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
gotten:
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
http://www.cygnus.com/misc/gnu-win32/faq.html#SEC57
says:
-----
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
updated.
Dave
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-Transfer-Encoding: 7bit
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: gnu-win32@cygnus.com, colin@bird.fu.is.saga-u.ac.jp
To: David W Palmer <David_W_Palmer@ccm.jf.intel.com>
MIME-Version: 1.0
X-Mailer: Mozilla 3.01Gold (WinNT; I)
Organization: JQB Enterprises
From: Jim Balter <jqb@netcom.com>
Date: Thu, 27 Mar 1997 13:20:09 -0800
Message-ID: < 333AE489.3ED1@netcom.com >
Received: from sba-ca1-24.ix.netcom.com(204.32.201.56) 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 [206.214.98.10]) 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 [134.134.248.4]) 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)
Return-Path: jqb@netcom.com
-
For help on using this list, send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".
More information about the Cygwin
mailing list