This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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







Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]