Library dynamic dependencies on Solaris

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,
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/libmydb.so when 
compiling myapi it will find libmydb.so only if I place libmydb.so in the 
subdirectory ./release.  Alternatively, if I use the option  -L ./release 
-lmydb when compiling myapi it will not be able to find mydb.

IN DETAIL:
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/libmydb.so -D_NDEBUG 
$(MYDB_OBJS)

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

However, libmyapi.so can't find libmydb.so:
$ ldd release/libmyapi.so
        libmydb.so =>    (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/libmydb.so $(DIR_API)/MyAPI.cpp 
$(DIR_API)/MyAPI.h $(DIR_API)/StdAfx.cpp
        g++ -shared -O3 -fPIC -o ./release/libmyapi.so -D_SOLARIS \
                -LDIR ./release/libmydb.so "$(DIR_API)/MyAPI.cpp" 
$(DIR_API)/StdAfx.cpp $(components)

In this case, libmyapi.so can find libmydb.so only in the ./release 
directory:
$ ldd release/libmyapi.so
        libmydb.so =>    ./release/libmydb.so

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

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

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux