This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
g++ library question
- From: Philip Cheng <cheng at pcigeomatics dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Fri, 4 Jul 2003 17:52:03 -0400 (EDT)
- Subject: g++ library question
Dear List:
I am using g++ to create a shared object library and I have a problem
with the library path. Here is an example:
I created a shared object library in a directory called TEMP
g++ -shared -o libtest.so sub.o
Then I go to main directory and use gcc to build my program
gcc test.c TEMP/libtest.so -o TEST
The program TEST always looks for TEMP/libtest.so when running.
It runs without problem when I run it in the main directory.
If I run the program TEST in another directory, it will complain
TEMP/libtest.so cannot be found.
When I typed ldd TEST in my main directory, it reported
TEMP/libmyshare.so => TEMP/libmyshare.so (0x40017000)
When I type ldd TEST in another directory, it reported
TEMP/libmyshare.so => not found
Is there a flag in gcc or g++ to remove the directory path in the
shared object library? If I use ld to build the shared library,
it does not contain the directory path TEMP and hence I can use
the LD_LIBRARY_PATH to specify the library path.
Thanks
Philip