Monday, August 11, 2008

How to find the shared library

Sometimes after you install the software on linux, when you run it,, it will warn you

cannot open shared object file: No such file or directory

For example , I can not find the opencv library "", so I type:

~$ whereis /usr/lib/ /usr/local/lib/ /usr/local/lib/ /usr/local/lib/

~$ locate

you can open "/etc/"
if you can not find /usr/local/lib in that file, you should add this file as root.
else if you see it in , you can do:
~# /sbin/ldconfig
you run ldconfig to update share library link.

Maybe you worry about if the opencv library work because you see old version in /usr/lib, the new version in /usr/local/lib,and the contain two directory .

Don't worry about that, because the linux 's shared library is linked dynamically.
You can go to /usr/lib and type:

~$ ls -al libcv*
You will find:

lrwxrwxrwx 1 root root 28 2006-07-23 16:21 -> /usr/local/lib/
lrwxrwxrwx 1 root root 25 2006-07-23 16:16 -> /usr/local/lib/

so they link with each other now. Linux can find the new version automatically (by name ).

We learn that after we install shared library, we should update dynamic link in the system by "ldconfig". Before do this , you should check if the shared library's route in the "/etc/"

No comments: