This is the mail archive of the mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re[2]: Linking with .LIB files

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 
     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.


Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset=us-ascii
References: <Thu, 27 Mar 97 12:33:08>
Subject: Re: Linking with .LIB files
To: David W Palmer <>
MIME-Version: 1.0
X-Mailer: Mozilla 3.01Gold (WinNT; I)
Organization: JQB Enterprises
From: Jim Balter <>
Date: Thu, 27 Mar 1997 13:20:09 -0800
Message-ID: <>
Received: from by
 via smap (V1.3)
     id sma006293; Thu Mar 27 15:23:33 1997
Received: (from smap@localhost)
          by (8.8.4/8.8.4)
       id PAA06304; Thu, 27 Mar 1997 15:23:58 -0600 (CST)
Received: from ( []) b
y (8.8.5/8.7.3) with ESMTP id NAA20601 for <David_W_Palmer@>; Thu, 27 Mar 1997 13:32:57 -0800 (PST)
Received: from ( []) by re (8.7.6/8.7.3) with ESMTP id NAA24313 for <David_W_Palmer@ccm.jf>; Thu, 27 Mar 1997 13:30:39 -0800 (PST)
For help on using this list, send a message to
"" with one line of text: "help".

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]