adding a non standard library path to linux library path
20 Jun 2014Sometimes when you compile some libraries like opencv, they install the compiled shared libraries in non standard path /usr/local/opencv/lib
instead of /usr/lib
or /usr/local/lib
. So when you try to compile your code against these libraries, gcc will not be able to locate them or when you are using python bindings, python wont be able to locate them. The errors will be something like this:
error while loading shared libraries: libopencv_core.so.2.4:
You need to add them to linux library path. Create a file /etc/ld.so.conf.d/opencv.conf
and put the path of your library in it.
/usr/local/opencv/lib
After this run:
sudo ldconfig
Then run sudo ldconfig -v
to check if it was located.
If you are not sure about the path of the installed libraries you can use the locate
utility. If locate is not able to find the path and you are sure that you have installed it, run this to update the index.
sudo updatedb