Operating System - HP-UX
1832231 Members
2924 Online
110041 Solutions
New Discussion

shared libraries, internal names and search paths

 
SOLVED
Go to solution
Jim Gallagher
Occasional Advisor

shared libraries, internal names and search paths

I am using boost-build to manage a project consisting of several libraries,
many of which depend on libraries that are part of the project. Boost-build
builds link lines that specify dependent libraries using a relative path to
the library, rather than using the typical -L -l
options. This causes a problem because the linker embeds the dependent library
name as the entire path passed on the link line. In an attempted work around,
I told boost build to build each lib with an internal name using the +h
linker option. This seems to work OK when I have a single dependency, but
fails when I have more than one. For example, suppose I have three libs, foo,
bar and baz, bar depends on foo and baz depends on bar, each built in their own
directory. The first two libraries get built like so:


$ cd foo; aCC -c foo.c; aCC -b -Wl,+h,libfoo.so -olibfoo.so foo.o ; cd ..
$ cd bar; aCC -c -I../foo bar.c; aCC -b -Wl,+h,libbar.so -olibbar.so bar.o ../foo/libfoo.so ; cd ..

The problem comes when I build the third:
$ cd baz; aCC -c -I../bar baz.c; aCC -b -olibbaz.so baz.o ../bar/libbar.so
ld: Can't find dependent library "libfoo.so"
Fatal error.


Even if I add libfoo to the link line, I get the same error:
$ aCC -b -olibbaz.so baz.o ../bar/libbar.so ../foo/libfoo.so
ld: Can't find dependent library "libfoo.so"
Fatal error.

However, if I add a search path, it links:
$ aCC -b -olibbaz.so baz.o ../bar/libbar.so -L../foo

Shouldn't the linker use the libraries supplied on the command line to satisfy
dependencies?

Thanks,
Jim Gallagher
1 REPLY 1
Dennis Handly
Acclaimed Contributor
Solution

Re: shared libraries, internal names and search paths

>build each lib with an internal name using the +h

I wouldn't think that's the purpose of +h but it works.

If you leave off -Wl,+h, it also links. But I suppose you want to solve the issue in your other thread:
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1347136

>Shouldn't the linker use the libraries supplied on the command line to satisfy
dependencies?

Why? These can be completely different files:
libfoo.so from the dependent shlib and ../foo/libfoo.so.

>if I add a search path, it links:

Yes, -L also affects searching for dependent shlibs.