tags:

views:

137

answers:

2

Hello,

I have some 3rd party libraries and includes (I have copied them to the this location /usr/ssd/include and /usr/ssd/lib) that I need to link with my application. I have just created a test application to see if I can link ok. However, when I try to run my app I get the following message.

./app: error while loading shared libraries: libssdn.so: cannot open shared object file: No such file or directory

On the command line I am compiling like this:

gcc -g -Wall -I/usr/ssd/include -L/usr/ssd/lib -lssdn test_app.c -o app

Everything compiles ok, as I don't get any warnings or errors. However, I get the error when I try and run the app.

In the usr/ssd/lib the library is called libssdn.so

I am been looking for solution and I have read something about -rpath, -Wl and LD_LIBRARY_PATH, but not sure what they are and how to include them when I compile.

I am using Ubuntu 9.04 Linux,

Thanks for any advice,

+1  A: 

My personal preference is not to bake the location of a shared object into an executable (which is what -rpath would do).

Instead, you should add /usr/ssd/lib to your LD_LIBRARY_PATH at run time. Assuming you are running bash or a bash like shell, do:

export LD_LIBRARY_PATH=/usr/ssd/lib:${LD_LIBRARY_PATH}

and once you do that, you can run your executable.

R Samuel Klatchko
Hello, that worked ok. However, if I was to run my application on another linux machine. Would I have the same problem? Sorry, but I couldn't understand the different of using -rpath and LD_LIBRARY_PATH. Thanks.
robUK
-rpath essentially bakes the LD_LIBRARY_PATH into the program itself so you don't have to add it to LD_LIBRARY_PATH. If *every* machine has the library in the same location, -rpath is fine. But if you want to run your program on a machine where the library is in a different path, -rpath is not the way to go.
R Samuel Klatchko
+1  A: 

Test if adding /usr/ssd/lib to your $LD_LIBRARY_PATH helps:

In a shell:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/ssd/lib

If that solves the problem, make it permanent by adding /usr/ssd/lib to /etc/ld.so.conf or by running

ldconfig -n /usr/ssd/lib
ChristopheD