This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Help needed for linking nested dynamic library
- From: "Gong, Richard" <richard dot gong at glenayre dot com>
- To: "'gcc-help at gcc dot gnu dot org'" <gcc-help at gcc dot gnu dot org>
- Date: Tue, 27 May 2003 05:43:17 -0400
- Subject: Help needed for linking nested dynamic library
Hi,
I got a problem to call a dynamic library if this dynamic library itself
also needs another dynamic library:
1) Let's say we uses ACE/TAO libraries: libACE.so, this file is under
/usr/local/ACE+TAO/ace
2) My program, test1.cpp will use the CORBA functions at libACE.so, so
I make the file as following:
export LD_LIBRARY_PATH=/usr/local/ACE+TAO/ace
g++ -D_POSIX_THREADS -D_POSIX_THREAD_SAFE_FUNCTIONS -D_REENTRANT
-DACE_HAS_AIO_CALLS -shared -fPIC -O3 -W -Wall -Wpointer-arith -pipe
-Wno-uninitialized -march=i686 -I/usr/local/ACE+TAO/ace -o test1.o -c
test1.cpp
ar rsuv libcppapi.a test1.o
3) Now, I need to build another dynamic library which is a JNI library
and will call the function at test1.cpp:
g++ -o libjava.so -z text -shared -lcppapi xxx.o
4) We have a Java program (test.java), it loads libjava.so and can call
ACE/TAO functions without any problem at the same machine.
5) Now, I moved the program to another machine, which installs the
ACE/TAO at different location (/usr/local/ACE_wrappers), I set the
LD_LIBRARY_PATH to the proper directories and run it again, but this time I
hit the following error:
Exception in thread "main" java.lang.UnsatisfiedLinkError:
/usr/lib/libjava.so: /usr/local/ACE+TAO/ace/libACE.so: cannot open shared
object file: No such file or directory
at java.lang.ClassLoader$NativeLibrary.load(Native
Method)
at
java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1473)
at
java.lang.ClassLoader.loadLibrary(ClassLoader.java:1397)
at java.lang.Runtime.loadLibrary0(Runtime.java:788)
at java.lang.System.loadLibrary(System.java:832)
It seems the path is hard coded at the library, not really looking for
LD_LIBRARY_PATH.
Much appreciated if you could help to solve the problem, i.e. how to make
the files properly so that it can search the library dynamically.
Thanks.