Re: gnu linker and static/dynamic mix

"Arthur H. Gold" <agold@bga.com>
12 May 2000 22:29:13 -0400

          From comp.compilers

Related articles
gnu linker and static/dynamic mix rakerr@sandia.gov (Robert Kerr) (2000-05-10)
Re: gnu linker and static/dynamic mix agold@bga.com (Arthur H. Gold) (2000-05-12)
| List of all articles for this month |
From: "Arthur H. Gold" <agold@bga.com>
Newsgroups: comp.compilers
Date: 12 May 2000 22:29:13 -0400
Organization: UTCS OOPS Group
References: 00-05-046
Keywords: linker

Robert Kerr wrote:
>
> I'm having a problem with the gnu linker. Here's my situation: I'm
> compiling on linux, using g++ (egcs 2.91.66) and letting it call ld
> (2.9.1). I need to link with all static libraries, with one
> exception. That exception is a set of commercial libraries that I
> only have dynamic versions of.
>
> If I needed all static, I'd just add -static to the g++ flags, and
> everything would be hunky-dory. But, when I do that, the linker
> complains about not finding the static versions of the commercial
> libraries. So, I thought "Why don't I use the -static flag to g++,
> then surround my commercial libraries with -Wl,-Bdynamic and
> -Wl,-Bstatic?" Well, I did that, and the linker finished much too
> rapidly (the fully-dynamic linked executable is about 55 MB, the
> partially dynamic one from the above method is only about 16 MB) and
> it doesn't execute correctly. When I try to run it it acts as if it
> isn't there (I get the (No such file or directory) error message).
>
> So, I tried adding -Wl,-aarchive to the link flags, then doing the
> -Bdynamic,-Bstatic pair around the dynamic libraries. It links too
> fast, and then when I try to run it I get a segfault. Running ldd on
> this executable shows that it's still linking dynamically to libm,
> libc, and libstdc++2.8.0.
>
> So, am I approaching this wrong? Is there some reason this isn't
> working for me? Thanks for any advice you might have.


Have you looked at the actual invocation of ld? (add '-Wl,-v' to your
g++ invocation to get this). It may not be producing the ld invocation
you think.
I've used -Xlinker -Bstatic <static libs> -Xlinker -Bdynamic <dynamic
libs> with appropriate results.


HTH,
--ag


--
Artie Gold, Austin, TX (finger the cs.utexas.edu account for more info)
mailto:agold@bga.com or mailto:agold@cs.utexas.edu


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.