Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I use a Linux executable, the libraries are located in many place. I mean the same library with different version. The problem is the executable picks up the executable in wrong library. The OS is Ubuntu 64 bit.

The libraries are located /usr/local/lib and /usr/lib/x86_64-linux-gnu. I would like that it would use /usr/local/lib version.

To force it to use the /usr/local/lib version. I copied the .so from there to /usr/lib/x86_64-linux-gnu and deleted .so referenced there. The result was that the software (VLC) did not use the newly copied libraries but it stopped working properly and it did not find the library at all. Despite of the fact, it was over there. So it is not clear how VLC decides what library to use.

It is clear that it uses the files under /etc/ld.so.conf.d to get the library paths. (Files contain /usr/local/lib and /usr/lib/x86_64-linux-gnu) WHy does not it choose the library I copied under /usr/lib/x86_64-linux-gnu or under /usr/local/lib ?

LD_LIBRARY_PATH is not set.

Update:

I thought I could just add another version , the program would use that but it seems that the version of the library is set at compile time for the given executable. so it will not use the new version, just because I delete an old one.

share|improve this question

migrated from stackoverflow.com Mar 20 '13 at 10:03

This question came from our site for professional and enthusiast programmers.

    
LD_LIBRARY_PATH is not set. <- that is your problem –  Gung Foo Mar 20 '13 at 8:40
    
Why do you say that? –  Aftershock Mar 20 '13 at 8:52
    
because that is where libraries are searched for. –  Gung Foo Mar 20 '13 at 9:00
    
Aren't those things set when the program is compiled and linked? Please provide more details including specific errors and the library in question. –  Ярослав Рахматуллин Mar 20 '13 at 10:09
    
yes, I thought I could just add another version , the program would use that but it seems that the version of the library is set at compile time. so it will not use the new version, just because I delete an old one. –  Aftershock Mar 20 '13 at 10:34
add comment

1 Answer 1

up vote 0 down vote accepted

Two ways this can be achieved

a) Setting rpath at linktime - this is a very ugly and unportable way and should be avoided whereever possible

b) Using the LD_LIBRARY_PATH environment variable (don't forget to export that if you change it!)


If you want to use a specific version/modified/foo-reason for your binary I suggest to

a) link against it statically if the license allows that

b) use LD_PRELOAD like explained here http://stackoverflow.com/questions/426230/what-is-the-ld-preload-trick

c) modify the LD_LIBRARY_PATH (make sure your path is the very first in that list, they are searched in order) by using a run-script which does that

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.