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 "libcv.so.1", so I type:

~$ whereis libcv.so.1

libcv.so: /usr/lib/libcv.so.0 /usr/local/lib/libcv.so.0 /usr/local/lib/libcv.so.1 /usr/local/lib/libcv.so

~$ locate libcv.so.1
/usr/local/lib/libcv.so.1
/usr/local/lib/libcv.so.1.0.0

you can open "/etc/ld.so.conf"
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 ld.so.conf 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 libcvaux.so.0 -> /usr/local/lib/libcvaux.so.0
lrwxrwxrwx 1 root root 25 2006-07-23 16:16 libcv.so.0 -> /usr/local/lib/libcv.so.0


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/ld.so.conf"

No comments: