Languages and Scripting
cancel
Showing results for 
Search instead for 
Did you mean: 

Incorrect embedded library names in shared library

SOLVED
Go to solution
Jim Gallagher
Occasional Advisor

Incorrect embedded library names in shared library

Hi,

While building a shared library, I noticed that if I pass a path to a dependent shared library on the link line (as opposed to using the -l and -L linker options), the path is embedded in the new library. For example, building libbar that depends on libfoo:

$ aCC -AA -b +DD64 -g -mt -o libbar.so bar.o ../foo/bin/libfoo.so

results in:
$ chatr libbar.so
libbar.so:
64-bit ELF shared library
shared library dynamic path search:
LD_LIBRARY_PATH enabled first
SHLIB_PATH enabled second
embedded path enabled third /usr/lib/hpux64:/opt/langtools/lib/hpux64
shared library list:
../foo/bin/libfoo.so
libpthread.so.1
.
.
.

The name of libfoo.so is embedded with the path used on the link line. Now libbar will only load if the relative path to libfoo.so resolves- LD_LIBRARY_PATH and SHLIB_PATH do not work. Is this the way it should work? I would think that just the name of the library should be embedded.

Thanks,
Jim Gallagher


4 REPLIES
James R. Ferguson
Acclaimed Contributor
Solution

Re: Incorrect embedded library names in shared library

Jim Gallagher
Occasional Advisor

Re: Incorrect embedded library names in shared library

JRF,

That was a very fast reply, thank you.

I ran into this using Boost-Build to run the the build of a several library project. Do you know if this behavior is similar on other Unix variants?

Thanks,
Jim
Dennis Handly
Acclaimed Contributor

Re: Incorrect embedded library names in shared library

If not clear from JRF's link you should be using -L and -l:
-L../foo/bin -lfoo

(You should also be putting foo in a lib/ directory, not bin/.)
Highlighted
Jim Gallagher
Occasional Advisor

Re: Incorrect embedded library names in shared library

ok