Library dynamic dependencies on Solaris

Kirsten Mayer
Wed Sep 13 01:17:00 GMT 2006

I need to distribute a custom dynamic library (or api) that depends on 
another dynamic library (a database) but I can't get the database to be 
found by the api except by putting the database in a specific directory, 
which means whoever uses my library must replicate my directory structure.

Specifically, if I use the option -LDIR ./release/ when 
compiling myapi it will find only if I place in the 
subdirectory ./release.  Alternatively, if I use the option  -L ./release 
-lmydb when compiling myapi it will not be able to find mydb.

I am building two C++ libraries on Solaris release 5.9 using gcc 2.95.3. 
One library, called "myapi", needs to link dynamically to the other, 
called "mydb". 
I have tried the following commands to build each library:

mydb: $(MYDB_OBJS)
        g++ -fPIC -lstdc++ -shared -lz -o ./release/ -D_NDEBUG 

myapi: $(components) mydb $(DIR_API)/MyAPI.cpp $(DIR_API)/MyAPI.h 
        g++ -shared -O3 -fPIC -o ./release/ -D_SOLARIS 
                 -L ./release -lmydb -R . $(DIR_API)/MyAPI.cpp 
$(DIR_API)/StdAfx.cpp $(components)

However, can't find
$ ldd release/ =>    (file not found)

The best I can do to find the library that myapi depends on is put it into 
a fixed directory with this command:

myapi : $(components) ./release/ $(DIR_API)/MyAPI.cpp 
$(DIR_API)/MyAPI.h $(DIR_API)/StdAfx.cpp
        g++ -shared -O3 -fPIC -o ./release/ -D_SOLARIS \
                -LDIR ./release/ "$(DIR_API)/MyAPI.cpp" 
$(DIR_API)/StdAfx.cpp $(components)

In this case, can find only in the ./release 
$ ldd release/ =>    ./release/

I don't want users of to have to create a ./release 
subdirectory to be able to use

If someone can tell me what command I should use, I would be very 
Many thanks in advance.

More information about the Gcc-help mailing list