My colleague contacted me yesterday, he deployed a new version of MS software and prompted that the dynamic library could not be found. But he can find this dynamic library file, but he doesn't know how to load it. Such a problem is very simple for me, but for a novice, it may be a problem that I don't know how to solve. So I want to write an article on this simple question, hoping to inspire colleagues who are new to such questions.
There are three ways to load dynamic libraries that I know. They are to put the library under /usr/lib64; modify /etc/ld.so.conf and add a conf file under /etc/ld.so.conf.d, and wrap the path into this file.
1: Put it directly under /etc/lib64, and then use the root user to call ldconfig to load and take effect. Use ldconfig -v|grep xxx to see if the loading is successful.
ln -s libvo-amrwbenc.so.0.0.4 libvo-amrwbenc.so
ln -s libopencore-amrnb.so.0.0.3 libopencore-amrnb.so
ln -s libx264.so.160 libx264.so
ln -s libunimrcpclient.so.0.5.0 libunimrcpclient.so
ln -s libasrclient.so.0.5.0 libasrclient.so
ln -s libunimrcpserver.so.0.5.0 libunimrcpserver.so
ln -s libapr-1.so.0.5.2 libapr-1.so
ln -s libaprutil-1.so.0.5.4 libaprutil-1.so
ln -s libsofia-sip-ua.so.0.6.0 libsofia-sip-ua.so
ln -s libunimrcpclient.so.0.5.0 libunimrcpclient.so
ln -s libunimrcpserver.so.0.5.0 libunimrcpserver.so
ln -s libexpat.so.0.5.0 libexpat.so
[ms@system-2-new etc]$ ldconfig -v|grep amr
ldconfig: Can't stat /libx32: No such file or directory
ldconfig: Path `/usr/lib' given more than once
ldconfig: Path `/usr/lib64' given more than once
ldconfig: Can't stat /usr/libx32: No such file or directory
ldconfig: /usr/local/lib/libavfilter.so.7 is not a symbolic link
ldconfig: /usr/local/lib/libavdevice.so.58 is not a symbolic link
ldconfig: /usr/local/lib/libpostproc.so.55 is not a symbolic link
ldconfig: /usr/local/lib/libavcodec.so.58 is not a symbolic link
libopencore-amrwb.so.0 -> libopencore-amrwb.so.0.0.3
libopencore-amrnb.so.0 -> libopencore-amrnb.so.0.0.3
ldconfig: /usr/local/lib/libavformat.so.58 is not a symbolic link
libvo-amrwbenc.so.0 -> libvo-amrwbenc.so.0.0.4
ldconfig: /usr/local/lib/libswscale.so.5 is not a symbolic link
ldconfig: /usr/local/lib/libswresample.so.3 is not a symbolic link
ldconfig: /usr/local/lib/libavutil.so.56 is not a symbolic link
ldconfig: Can't create te
2: Modify the ld.so.conf file, put the directory of the dynamic library into the modified file, then call ldconfig to load, and call ldconfig -v|grep xxxx to check whether the loading is successful.
[ms@system-2-new etc]$ vi ld.so.conf
include ld.so.conf.d/*.conf
/usr/local/lib/
/usr/local/unimrcp/lib/
/usr/local/apr/lib/
/usr/local/lib64/
ldconfig
ldconfig -v|grep amr
3: Create a file in the /etc/ld.so.conf.d directory, and put the file path of the dynamic library in the conf file
[ms@system-2-new etc]$ cd /etc/ld.so.conf.d
[ms@system-2-new ld.so.conf.d]$ ls
atlas-x86_64.conf kernel-3.10.0-862.el7.x86_64.conf llvm-x86_64.conf
dyninst-x86_64.conf libiscsi-x86_64.conf mariadb-x86_64.conf
[ms@system-2-new ld.so.conf.d]$
[ms@system-2-new ld.so.conf.d]$ vi mariadb-x86_64.conf
/usr/lib64/mysql
[root@system-2-new ~]# ldconfig -v|grep mysql
ldconfig: Can't stat /libx32: No such file or directory
ldconfig: Path `/usr/lib' given more than once
ldconfig: Path `/usr/lib64' given more than once
ldconfig: Can't stat /usr/libx32: No such file or directory
ldconfig: /usr/local/lib/libavfilter.so.7 is not a symbolic link
ldconfig: /usr/local/lib/libavdevice.so.58 is not a symbolic link
ldconfig: /usr/local/lib/libpostproc.so.55 is not a symbolic link
ldconfig: /usr/local/lib/libavcodec.so.58 is not a symbolic link
ldconfig: /usr/local/lib/libavformat.so.58 is not a symbolic link
ldconfig: /usr/local/lib/libswscale.so.5 is not a symbolic link
ldconfig: /usr/local/lib/libswresample.so.3 is not a symbolic link
ldconfig: /usr/local/lib/libavutil.so.56 is not a symbolic link
/usr/lib64/mysql:
libmysqlclient.so.20 -> libmysqlclient.so.20.3.14
libmysqlclient.so.18 -> libmysqlclient.so.18.0.0
[root@system-2-new ~]#
Summarize:
There are three ways to load dynamic libraries that I know. They are to put the library under /usr/lib64; modify /etc/ld.so.conf and add a conf file under /etc/ld.so.conf.d, and wrap the path into this file. Use the ldconfig command under root to load and take effect, and use ldconfig -v|grep xxx to check whether it takes effect.