public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Re: Linking with -lkernel32 [was: Re: beta18: building gdb gives incomplete import table [and other problems]???]
@ 1998-01-05  7:54 marcus
  0 siblings, 0 replies; 3+ messages in thread
From: marcus @ 1998-01-05  7:54 UTC (permalink / raw)
  To: gnu-win32

Fergus Henderson <fjh@cs.mu.OZ.AU> writes:
> Whether or not you need to specify `-lkernel32' etc. explicitly
> depends on whether you are using `gcc' to do the link, or whether
> you are invoking `ld' directly.  If you're using `gcc' to do the link,
> it will pass `-lkernel32' etc., so you don't need to (and in fact must not)
> specify it yourself.  If you're invoking `ld' directly, then yes you
> do need to specify it explicitly.

This is exactly correct.
 
> > If I understand correctly, you use "-lgcc -lcygwin -lkernel32 -lgcc" among
> > other obvious things.
> > So, should we, or should we not repeat libs?
> 
> I think repeating ordinary libraries (e.g. `-lgcc') is OK;
> I think it is only DLL import libraries (e.g. `-lcygwin' or `-lkernel32')
> that cause problems if they are linked twice.
> (However, this is basically just educated guesswork.)

This is also exactly correct.  The reason is that there is a delicate dance
done with various sections (.idata$2, etc.) to build the DLL import table.
If a DLL import library is included multiple times, this dance gets out of
step and the import table ends up built incorrectly.

Since archive libraries do not do this, it is not harmful to include them
multiple times.

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

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

* Re: Linking with -lkernel32 [was: Re: beta18: building gdb gives incomplete import table [and other problems]???]
  1997-12-31  7:33     ` Linking with -lkernel32 [was: Re: beta18: building gdb gives incomplete import table [and other problems]???] Joao Pedro Sousa
@ 1997-12-31 21:16       ` Fergus Henderson
  0 siblings, 0 replies; 3+ messages in thread
From: Fergus Henderson @ 1997-12-31 21:16 UTC (permalink / raw)
  To: Joao Pedro Sousa; +Cc: gnu-win32

On 31-Dec-1997, Joao Pedro Sousa <js@servisoft.pt> wrote:
> At 12:34 31-12-1997 +1100, Fergus Henderson wrote:
> >...
> >One bug with the linker that has been mentioned on this list previously
> >is that if the same library name is mentioned twice on the link line,
> >then the linker generates executables that crash.  `-lkernel32' is
> >linked in by default, so if you mention it explicitly then it will
> >get linked in twice, causing the symptoms you observed.
> I can't successfully link DLLs (relocatable or non-relocatable) if I don't
> include:
>    -lc -lcygwin -lkernel32 -lc

Whether or not you need to specify `-lkernel32' etc. explicitly
depends on whether you are using `gcc' to do the link, or whether
you are invoking `ld' directly.  If you're using `gcc' to do the link,
it will pass `-lkernel32' etc., so you don't need to (and in fact must not)
specify it yourself.  If you're invoking `ld' directly, then yes you
do need to specify it explicitly.

> If I understand correctly, you use "-lgcc -lcygwin -lkernel32 -lgcc" among
> other obvious things.
> So, should we, or should we not repeat libs?

I think repeating ordinary libraries (e.g. `-lgcc') is OK;
I think it is only DLL import libraries (e.g. `-lcygwin' or `-lkernel32')
that cause problems if they are linked twice.
(However, this is basically just educated guesswork.)

-- 
Fergus Henderson <fjh@cs.mu.oz.au>   |  "I have always known that the pursuit
WWW: < http://www.cs.mu.oz.au/~fjh >   |  of excellence is a lethal habit"
PGP: finger fjh@128.250.37.3         |     -- the last words of T. S. Garp.
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

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

* Linking with -lkernel32 [was: Re: beta18: building gdb gives incomplete import table [and other problems]???]
  1997-12-30 17:34   ` beta18: building gdb gives incomplete import table [and other problems]??? Fergus Henderson
@ 1997-12-31  7:33     ` Joao Pedro Sousa
  1997-12-31 21:16       ` Fergus Henderson
  0 siblings, 1 reply; 3+ messages in thread
From: Joao Pedro Sousa @ 1997-12-31  7:33 UTC (permalink / raw)
  To: Fergus Henderson; +Cc: gnu-win32

At 12:34 31-12-1997 +1100, Fergus Henderson wrote:
>...
>One bug with the linker that has been mentioned on this list previously
>is that if the same library name is mentioned twice on the link line,
>then the linker generates executables that crash.  `-lkernel32' is
>linked in by default, so if you mention it explicitly then it will
>get linked in twice, causing the symptoms you observed.
>
>-- 
>Fergus Henderson <fjh@cs.mu.oz.au>   |  "I have always known that the pursuit
>WWW: < http://www.cs.mu.oz.au/~fjh >   |  of excellence is a lethal habit"
>PGP: finger fjh@128.250.37.3         |     -- the last words of T. S. Garp.

I can't successfully link DLLs (relocatable or non-relocatable) if I don't
include:
   -lc -lcygwin -lkernel32 -lc

Also, this is somewhat consistent with your Makefile.DLLs, an excerpt of
which I pasted next:
(...)
# The `sed' commands below are to convert DOS-style `C:\foo\bar'
# pathnames into Unix-style `//c/foo/bar' pathnames.
CYGWIN32_LIBS = $(shell echo                                    \
        -L`dirname \`gcc -print-file-name=libgcc.a |            \
        sed -e 's@^\\\\([A-Za-z]\\\\):@//\\\\1@g' -e 's@\\\\\\\\@/@g' \` ` \
        -L`dirname \`gcc -print-file-name=libcygwin.a | \
        sed -e 's@^\\\\([A-Za-z]\\\\):@//\\\\1@g' -e 's@\\\\\\\\@/@g' \` ` \
        -L`dirname \`gcc -print-file-name=libkernel32.a | \
        sed -e 's@^\\\\([A-Za-z]\\\\):@//\\\\1@g' -e 's@\\\\\\\\@/@g' \` ` \
        -lgcc -lcygwin -lkernel32 -lgcc)

# Making relocatable DLLs doesn't seem to work.
# Note quite sure why.  The --image-base values below
# where chosen at random, they seem to work on my machine.
RELOCATABLE=no
LDFLAGS-libgc +=        --image-base=0x2345000
LDFLAGS-libmer +=       --image-base=0x1234000
LDFLAGS-libmercury +=   --image-base=0x3456000

ifeq "$(strip $(RELOCATABLE))" "yes"

# to create relocatable DLLs, we need to do two passes
# (warning: this is untested)
%.dll: %.exp %.a %_dll.o dll_init.o dll_fixup.o
        $(LD) $(LDFLAGS) $(LDFLAGS-$*) --dll -o $*.base                 \
                -e _dll_entry@12                                        \
                $*.exp $*.a $*_dll.o                                    \
                dll_init.o dll_fixup.o                                  \
                $(LDLIBS) $(LDLIBS-$*)                                  \
                $(CYGWIN32_LIBS)
(...)

If I understand correctly, you use "-lgcc -lcygwin -lkernel32 -lgcc" among
other obvious things.
So, should we, or should we not repeat libs?
By the way, is there a description of the available libs and their contents?

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

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

end of thread, other threads:[~1998-01-05  7:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-01-05  7:54 Linking with -lkernel32 [was: Re: beta18: building gdb gives incomplete import table [and other problems]???] marcus
  -- strict thread matches above, loose matches on Subject: below --
1997-12-29 15:44 beta18: building gdb gives incomplete import table [and other problems]??? Steven Reddie
1997-12-28 22:19 ` beta18: building gdb gives incomplete import table??? Steven Reddie
1997-12-30 17:34   ` beta18: building gdb gives incomplete import table [and other problems]??? Fergus Henderson
1997-12-31  7:33     ` Linking with -lkernel32 [was: Re: beta18: building gdb gives incomplete import table [and other problems]???] Joao Pedro Sousa
1997-12-31 21:16       ` Fergus Henderson

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