【Linux 日常】设置动态链接库目录
方法一:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:path_to_add
该方式为临时的,系统重启则失效。
方法二:
sudo vim /etc/ld.so.conf
添加库路径
保存后
执行命令 sudo ldconfig
可通过ldd 查询可执行文件的依赖项是否正确。
如:
root@VM-0-12-ubuntu:~/ocr/work# ldd /usr/local/bin/tesseract
linux-vdso.so.1 => (0x00007ffec1fe6000)
libtesseract.so.4 => /usr/local/lib/libtesseract.so.4 (0x00007faee8cb4000)
liblept.so.5 => /usr/local/lib/liblept.so.5 (0x00007faee8843000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6
(0x00007faee84b4000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007faee829d000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007faee7ed3000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0
(0x00007faee7cb6000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007faee79ac000)
libgomp.so.1 => /usr/lib/x86_64-linux-gnu/libgomp.so.1 (0x00007faee778a000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007faee7570000)
libpng12.so.0 => /lib/x86_64-linux-gnu/libpng12.so.0 (0x00007faee734a000)
libjpeg.so.8 => /usr/lib/x86_64-linux-gnu/libjpeg.so.8 (0x00007faee70f1000)
libtiff.so.5 => /usr/lib/x86_64-linux-gnu/libtiff.so.5 (0x00007faee6e7d000)
/lib64/ld-linux-x86-64.so.2 (0x000055a48fa6a000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007faee6c78000)
liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5 (0x00007faee6a56000)
libjbig.so.0 => /usr/lib/x86_64-linux-gnu/libjbig.so.0 (0x00007faee6847000)