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

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.

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

Sorry for the rampant uncertainty,

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] 5+ messages in thread

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

David W Palmer wrote:
> 
> 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:

I believe (but have not verified) that ld generates these.
So, if link doesn't produce some equivalent that can be
massaged/converted
into what cygwin.dll is expecting (libccrt0.o just stashes them for use
later
by cygwin.dll) you may be out of luck.  However, the _start_ and _end_
symbols
are only used by fork, which you probably aren't using, and the LISTs
are C++
ConstrucTOR and DesstrucTOR lists, which you probably also don't need. 
So, try
just defining all these to null in the link command line or script file,
or
define them in simple.c, and see how that goes.  You need to strip one
'_' if
you define them in a .c file on a x86 box (but not on a PowerPC box).
i.e., add

void (*__CTOR_LIST__)(void) = 0;
void (*__CTOR_LIST__)(void) = 0;
char _data_start__, _data_end__, _bss_start__, _bss_end__;

to simple.c and fire 'er up.

--
<J Q B>
-
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] 5+ messages in thread

* Re: Linking with .LIB files
  1997-03-26 17:32       ` David W Palmer
  1997-03-25 12:55         ` David W Palmer
  1997-03-26  9:44         ` Nick Ing-Simmons
@ 1997-03-27  0:57         ` Jim Balter
  2 siblings, 0 replies; 5+ messages in thread
From: Jim Balter @ 1997-03-27  0:57 UTC (permalink / raw)
  To: David W Palmer; +Cc: gnu-win32, colin

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

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

--
<J Q B>
-
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] 5+ messages in thread

* Re: Linking with .LIB files
  1997-03-26 17:32       ` David W Palmer
  1997-03-25 12:55         ` David W Palmer
@ 1997-03-26  9:44         ` Nick Ing-Simmons
  1997-03-27  0:57         ` Jim Balter
  2 siblings, 0 replies; 5+ messages in thread
From: Nick Ing-Simmons @ 1997-03-26  9:44 UTC (permalink / raw)
  To: David_W_Palmer; +Cc: gnu-win32

David W Palmer <David_W_Palmer@ccm.jf.intel.com> writes:
>     
>     link simple.o libuser32.a glu32.lib opengl32.lib libgdi32.a 
>     /subsystem:windows /machine:i386
>     
>     And of course, I get the following:
>     
>      Microsoft (R) 32-Bit Incremental Linker Version 5.00.7022
>      Copyright (C) Microsoft Corp 1992-1997. All rights reserved.
>      
>      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?


      link /entry:whatever_it_is_forGNU 


-
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] 5+ messages in thread

* Linking with .LIB files
  1997-03-26 17:32       ` David W Palmer
@ 1997-03-25 12:55         ` David W Palmer
  1997-03-26  9:44         ` Nick Ing-Simmons
  1997-03-27  0:57         ` Jim Balter
  2 siblings, 0 replies; 5+ messages in thread
From: David W Palmer @ 1997-03-25 12:55 UTC (permalink / raw)
  To: gnu-win32

     
     Yes, I know this has been covered before.  Unfortunately, I can't find 
     the necessary information to get this to work other than to use 
     link.exe and it might work.
     
     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
     
     And of course, I get the following:
     
      Microsoft (R) 32-Bit Incremental Linker Version 5.00.7022
      Copyright (C) Microsoft Corp 1992-1997. All rights reserved.
      
      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?
     
     Dave
-
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] 5+ messages in thread

end of thread, other threads:[~1997-03-27 15:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-03-26  9:44 Linking with .LIB files Colin Peters
  -- strict thread matches above, loose matches on Subject: below --
1997-03-27 20:59 Re[2]: " David W Palmer
     [not found] <25>
     [not found] ` <Mar>
     [not found]   ` <97>
     [not found]     ` <11:48:14>
1997-03-26 17:32       ` David W Palmer
1997-03-25 12:55         ` David W Palmer
1997-03-26  9:44         ` Nick Ing-Simmons
1997-03-27  0:57         ` Jim Balter
     [not found]     ` <12:33:08>
1997-03-31 12:13       ` Re[2]: " David W Palmer
1997-03-27 15:33         ` Jim Balter
1997-03-19 18:13 Understanding program startup DG Ellis

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