开发者

linking libraries -rpath LD_LIBRARY_PATH

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 librar开发者_如何学Cies: 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,


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜