问题出现场景
编写代码调用了动态库的函数,linux是要加载到环境中,所以引用动态库头文件并没有真正的使用到动态库,当编译代码,就会报以下的错误:
[root@localhost netproc]# ./client
./client: error while loading shared libraries: libitcastsocket.so: cannot open shared object file: No such file or directory
错误提示很明显提示没有找到动态库。
检测程序有那些没有加载的动态库:
[root@localhost netproc]# ldd client
linux-vdso.so.1 => (0x00007fff6f9ff000)
libitcastsocket.so => not found
libc.so.6 => /lib64/libc.so.6 (0x0000003a64000000)
/lib64/ld-linux-x86-64.so.2 (0x0000003a63800000)
加载缺失的动态库:
直接将文件目录下的动态库加载到环境中
export LD_LIBRARY_PATH=/netproc:$LD_LIBRARY_PATH
[root@localhost netproc]# ldd client
linux-vdso.so.1 => (0x00007fffd43ff000)
libitcastsocket.so => /netproc/libitcastsocket.so (0x00007f65fbf91000)
libc.so.6 => /lib64/libc.so.6 (0x0000003a64000000)
/lib64/ld-linux-x86-64.so.2 (0x0000003a63800000)