public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* RE: Re[2]: Linking with .LIB files
@ 1997-03-27 20:59 Colin Peters
  0 siblings, 0 replies; 4+ messages in thread
From: Colin Peters @ 1997-03-27 20:59 UTC (permalink / raw)
  To: 'David W Palmer'; +Cc: 'GNU-Win32'

David W Palmer[SMTP:David_W_Palmer@ccm.jf.intel.com] wrote:
>     For those who are watching: Colin Peter's text is left justified, mine is 
>     indented.
>
>David W Palmer[SMTP:David_W_Palmer@ccm.jf.intel.com] wrote:
>Although this may be secondary to your concerns, or in fact may be 
>totally off topic, I notice that libglu32.a and libopengl32.a are 
>both included with the beta 17.1 distribution. I'm not sure about 
>the header files, but if you can get your code to compile you should 
>be able to link it with ld. Of course this doesn't help if what you 
>really want is DirectX or some other thing that comes with .lib 
>files you can't convert to .a files.
>     
>     Actually, that is interesting.  From the distribution I downloaded, 
>     libglu32.a and libopengl32.a are not available.  However, I am 
>     interested in the general problem of linking with MS lib's (ie, 
>     glaux.lib).
>     
>     I suspect that I could use dlltool to generate an import library for 
>     glu32.dll and opengl32.dll.  I'll give it a try.

Actually I've got libglaux.a as well. Hang on a second and I'll look at
my original copy... they are definitely there. So it doesn't seem I
generated them myself later. In the original tarball I found them in
H-i386-cygwin32/i386-cygwin32/lib. Interestingly some of these (but
not all) have .def files included in the original Win32-API 0.1.2
package. In the Cygnus source distribution the def files appear in
src/winsup/sysdef/i386, and that should be all of them.

But back to the question of linking with .libs that you can't get
a .a for...

>>      LINK : error LNK2001: unresolved external symbol _WinMainCRTStartup 
[snip: include crt0.o?]
>     //f/pgming/OpenGL/simple$ make
>     link simple.o crt0.o libuser32.a glu32.lib opengl32.lib libgdi32.a 
>     /subsystem:windows /machine:i386
>     crt0.o : error LNK2001: unresolved external symbol _cygwin_crt0

Hmm, that would be in libcygwin32.a if I remember correctly.

>     So, I can trade WinMainCRTStartup() for cygwin_crt0().  Not much 
>     progress.  Though, this has to be defined somewhere!  Which library?  
>     Unfortunately, I don't know how to list the functions in a library. 
>     (how embarrassing) :+(

You can get a list of functions in a library fairly easily by using
nm (which lists symbol names):

  nm libfoo.a | grep T

Of course with sed and awk, or possibly the correct options to
nm (!) you can probably get cleaner output, but this is a useful
first cut. I often use nm libfoo.a | grep foobar to see if foobar
is in the foo library.

>     BTW: instead of defining WinMainCRTStartup(), it's easier to use the 
>     link option /ENTRY:mainCRTStartup.

This is true.

It seems from following other threads on this matter that the
whole effort may be doomed by some sort of "offset problem"
people seem to have with programs linked this way. Although
my memory may be failing me again. I have some information
which leads me to believe a bug in gas (or as if you like;
the assembler) may hurt your chances of getting this to work.

But anyway, good luck,

Colin.

-- Colin Peters - colin@bird.fu.is.saga-u.ac.jp
-- Saga University Dept. of Information Science
-- http://www.fu.is.saga-u.ac.jp/~colin/index.html
-- http://www.geocities.com/Tokyo/Towers/6162/

-
For help on using this list, send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re[2]: Linking with .LIB files
       [not found]       ` <12:12:26>
@ 1997-03-31 12:13         ` David W Palmer
  1997-03-27 20:59           ` David W Palmer
  0 siblings, 1 reply; 4+ messages in thread
From: David W Palmer @ 1997-03-31 12:13 UTC (permalink / raw)
  To: jqb; +Cc: gnu-win32, colin

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re[2]: Linking with .LIB files
  1997-03-31 12:13         ` David W Palmer
@ 1997-03-27 20:59           ` David W Palmer
  0 siblings, 0 replies; 4+ messages in thread
From: David W Palmer @ 1997-03-27 20:59 UTC (permalink / raw)
  To: jqb; +Cc: gnu-win32, colin

Text item: 

     
     Okay, I've pulled together the feedback and made a few more attempts.
     
     I compile the program using:
        gcc -o simple.c
     
     and link using:
     
     link simple.o libc.a libcygwin.a libkernel32.a libuser32.a glu32.lib 
     opengl32.lib libgdi32.a /subsystem:windows /machine:i386 
     /entry:mainCRTStartup
     
     The output:
     
//f/pgming/opengl/simple$ make
link simple.o libc.a libcygwin.a libkernel32.a libuser32.a glu32.lib opengl32.li
b libgdi32.a /subsystem:windows /machine:i386 /entry:mainCRTStartup
Microsoft (R) 32-Bit Incremental Linker Version 5.00.7022
Copyright (C) Microsoft Corp 1992-1997. All rights reserved.

libcygwin.a(libccrt0.o) : error LNK2001: unresolved external symbol ___CTOR_LIST
__
libcygwin.a(libccrt0.o) : error LNK2001: unresolved external symbol ___DTOR_LIST
__
libcygwin.a(libccrt0.o) : error LNK2001: unresolved external symbol __data_start
__
libcygwin.a(libccrt0.o) : error LNK2001: unresolved external symbol __data_end__

libcygwin.a(libccrt0.o) : error LNK2001: unresolved external symbol __bss_start_
_
libcygwin.a(libccrt0.o) : error LNK2001: unresolved external symbol __bss_end__
simple.exe : fatal error LNK1120: 6 unresolved externals
make: *** [simple.exe] Error 25
//f/pgming/opengl/simple$
     
     I greped the contents of every .a I could find and there's no trace of a 
     __data_start__ tag anywhere.  I grep them by doing the following:
     
        mkdir out
        for x in *.a; do nm $x > out/$x; done;
        cd out
        egrep data_start *
     
     This has the advantage of telling me which file any matches are found.  It 
     worked quite well for finding _GetModuleHandleA@4.  I also checked crt0.o 
     just in case.  Maybe the compiler was suppose to generate these symbols?  
     Or maybe it's something ld understands but link doesn't?
     
     Simple.c is a very simple windows program (with a WinMain) that calls 
     OpenGL primitives.  I copied it from a companion CD of a book to use for 
     testing this out.
     
     The GNU-Win32 I'm using I pulled from 
        ftp://ftp.cygnus.com/pub/gnu-win32/latest/all.tar.gz
     
     Apparently this is b17, not b17.1.  Sounds like getting the patches to 
     b17.1 should resolve the issue of using OpenGL.  Though I'm still 
     interested in getting this to work.  (call me stubborn if you like)
     
     So, any ideas about why I'm missing these symbols and what can I do about 
     it?
     
     Thanks, for the help guy's!  I do appreciate it!
     
     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: <Wed, 26 Mar 97 10:42:13 PST_6@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 00:46:40 -0800
Message-ID: < 333A33F0.4F58@netcom.com >
Received: from sba-ca1-24.ix.netcom.com(204.32.201.56) by dfw-ix16.ix.netcom.com
 via smap (V1.3)
     id sma025517; Thu Mar 27 02:49:47 1997
Received: (from smap@localhost)
          by dfw-ix16.ix.netcom.com (8.8.4/8.8.4)
       id CAA25617; Thu, 27 Mar 1997 02:50:13 -0600 (CST)
Received: from dfw-ix16.ix.netcom.com (dfw-ix16.ix.netcom.com [206.214.98.16]) b
y mailbag.jf.intel.com (8.8.5/8.7.3) with ESMTP id AAA23068 for <David_W_Palmer@
ccm.jf.intel.com>; Thu, 27 Mar 1997 00:59:15 -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 AAA28751 for <David_W_Palmer@ccm.jf
.intel.com>; Thu, 27 Mar 1997 00:56:55 -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".

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re[2]: Linking with .LIB files
       [not found]       ` <10:42:13>
@ 1997-03-26 17:32         ` David W Palmer
  0 siblings, 0 replies; 4+ messages in thread
From: David W Palmer @ 1997-03-26 17:32 UTC (permalink / raw)
  To: gnu-win32, colin

Text item: 


     For those who are watching: Colin Peter's text is left justified, mine is 
     indented.


David W Palmer[SMTP:David_W_Palmer@ccm.jf.intel.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
     
Although this may be secondary to your concerns, or in fact may be 
totally off topic, I notice that libglu32.a and libopengl32.a are 
both included with the beta 17.1 distribution. I'm not sure about 
the header files, but if you can get your code to compile you should 
be able to link it with ld. Of course this doesn't help if what you 
really want is DirectX or some other thing that comes with .lib 
files you can't convert to .a files.
     
     Actually, that is interesting.  From the distribution I downloaded, 
     libglu32.a and libopengl32.a are not available.  However, I am 
     interested in the general problem of linking with MS lib's (ie, 
     glaux.lib).
     
     I suspect that I could use dlltool to generate an import library for 
     glu32.dll and opengl32.dll.  I'll give it a try.
     
     
>      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?
     
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 
     /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().  Not much 
     progress.  Though, this has to be defined somewhere!  Which library?  
     Unfortunately, I don't know how to list the functions in a library. 
     (how embarrassing) :+(
     
     BTW: instead of defining WinMainCRTStartup(), it's easier to use the 
     link option /ENTRY:mainCRTStartup.


Sorry for the rampant uncertainty,

     Hay, at least it's better than calling me crazy for not using MSVC.  
     Actually, I am using VC++ 5.0 but I'd rather not.
     
     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"
MIME-Version: 1.0
Date: Wed, 26 Mar 1997 13:48:48 +0900
Subject: RE: Linking with .LIB files
Cc: "'GNU-Win32'" <gnu-win32@cygnus.com>
To: "'David W Palmer'" <David_W_Palmer@ccm.jf.intel.com>
From: Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
Message-ID: < 01BC39EC.6F6FE340@gbird0 >
Received: by gbird0 with Microsoft Mail
     id < 01BC39EC.6F6FE340@gbird0 >; Wed, 26 Mar 1997 13:48:50 +0900
Received: from gbird0 ([133.49.23.250]) by bird.fu.is.saga-u.ac.jp (8.8.2/3.3W7-
bird) with SMTP id NAA19950; Wed, 26 Mar 1997 13:49:13 +0900 (JST)
Received: from bird.fu.is.saga-u.ac.jp (bird.fu.is.saga-u.ac.jp [133.49.23.129])

          by ormail.intel.com (8.8.4/8.8.4) with ESMTP
       id UAA05410 for <David_W_Palmer@ccm.jf.intel.com>; Tue, 25 Mar 1997 20:51
:50 -0800 (PST)
Received: from ormail.intel.com (ormail.intel.com [134.134.248.3]) by relay.jf.i
ntel.com (8.7.6/8.7.3) with ESMTP id UAA04374 for <David_W_Palmer@ccm.jf.intel.c
om>; Tue, 25 Mar 1997 20:52:03 -0800 (PST)
Return-Path: colin@bird.fu.is.saga-u.ac.jp
-
For help on using this list, send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~1997-03-31 12:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-03-27 20:59 Re[2]: Linking with .LIB files Colin Peters
  -- strict thread matches above, loose matches on Subject: below --
1997-03-24 10:32 Windows API calls that don't work? (Was RE: Stupid stupi David W Palmer
1997-03-19 18:13 Understanding program startup DG Ellis
     [not found] ` <26>
     [not found]   ` <Mar>
     [not found]     ` <97>
     [not found]       ` <10:42:13>
1997-03-26 17:32         ` Re[2]: Linking with .LIB files David W Palmer
     [not found]       ` <12:12:26>
1997-03-31 12:13         ` David W Palmer
1997-03-27 20:59           ` David W Palmer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).