[prev in list] [next in list] [prev in thread] [next in thread]
List: hpux-cxx-dev
Subject: Re: CXX-DEV: Linking order in HP 11.00
From: Dennis Handly <dhandly () cup ! hp ! com>
Date: 2002-03-12 1:38:42
[Download RAW message or body]
>I have an archive library say libarchive.a. I have a shared library say
>libshared1.sl dependent on the archive library.
As mentioned, you should include the archive when you create the shared lib.
>aCC -o libarchive.a archive.o
Change to:
aCC +z -c archive.o
ar -cvr libarchive.a archive.o
aCC +z -b -o libshared1.sl shared1.cpp libarchive.a
>Two ways of making the final executable:
(1) aCC -Wl,+s -L. -lshared1
Now you only have one way.
>Note even though libshared1.sl depends on libarchive.a I haven't linked
>the archive library with the shared library during its creation (and
>this doesn't crib !!!!).
You shouldn't do this. If a shared lib is the only user of an archive,
then include the archive when you build the shared.
If the archive is used in multiple places, make a shared lib out of it.
>I had another shared library say libshared2.sl and repeated the same
>steps as given above, it wouldn't have mattered what the order of
>linking is
Right. dld.sl looks at all of the libs.
>Can someone please tell me why the order of linking is important in case
>you have an archive library.
Mahesha and Mike explained it. You can also use -Wl,+n to do multiple
pass over the link line.
>I read somewhere that aCC is a single pass compiler in contrast to say
>CC (Sun compiler) which is a multi-pass compiler. Can someone please
>explain me if this has any bearing on the example I just discussed.
Aveek
No bearing at all. aC++ is an N pass compiler.
I think you are talking about the linker instead and that is what the
difference occurs.
>From: "mahesha" <mahesha@india.hp.com>
>The linker searches libraries in the order in which they are specified on
>the command line - the link order. Link order is important in that a
>library containing an external reference to another library must precede the
>library containing the definition.
>From: "Rich Rauenzahn" <rrauenza@cup.hp.com>
>This isn't doing at all what you think it's doing. ar is used to create
>archive libraries.
Perhaps Aveek just explained it incorrectly?
>I don't see at all how libshared1.sl depends on libarchive from what you've
>shown above.
Depend is the wrong word. It may be valid English but is isn't valid
Nerdese. I.e. it isn't a shared library dependency.
It has unsats that the archive defines.
>Shouldn't you be linking the archive lib into the shared library when _it_
>is created?
Rich
It depends on how many people use it, or whether there is a PIC version.
>From: Mike Stroyan <stroyan@hpstryn.fc.hp.com>
>You can force all of an archive to be linked in using ld's -Fl or
>+forceload option.
Or add -Wl,-usym to only extract what is needed. Or swap the order.
_________________________________________________________________
To leave this mailing list, send mail to majordomo@cxx.cup.hp.com
with the message UNSUBSCRIBE cxx-dev
_________________________________________________________________
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic