Leo*_*zen 55 linux linker ffmpeg shared-libraries
被/usr/local/lib搜索的共享库?我有这个错误:
[Leo@chessman ~]$ whereis ffmpeg
ffmpeg: /usr/local/bin/ffmpeg
[Leo@chessman ~]$ ffmpeg
ffmpeg: error while loading shared libraries: libavcore.so.0: cannot open shared object file: No such file or directory
[Leo@chessman ~]$ ls /usr/local/lib/libav*
/usr/local/lib/libavcodec.a /usr/local/lib/libavfilter.a
/usr/local/lib/libavcodec.so /usr/local/lib/libavfilter.so
/usr/local/lib/libavcodec.so.52 /usr/local/lib/libavfilter.so.1
/usr/local/lib/libavcodec.so.52.108.0 /usr/local/lib/libavfilter.so.1.74.0
/usr/local/lib/libavcore.a /usr/local/lib/libavformat.a
/usr/local/lib/libavcore.so /usr/local/lib/libavformat.so
/usr/local/lib/libavcore.so.0 /usr/local/lib/libavformat.so.52
/usr/local/lib/libavcore.so.0.16.1 /usr/local/lib/libavformat.so.52.94.0
/usr/local/lib/libavdevice.a /usr/local/lib/libavutil.a
/usr/local/lib/libavdevice.so /usr/local/lib/libavutil.so
/usr/local/lib/libavdevice.so.52 /usr/local/lib/libavutil.so.50
/usr/local/lib/libavdevice.so.52.2.3 /usr/local/lib/libavutil.so.50.36.0
[Leo@chessman ~]$
Run Code Online (Sandbox Code Playgroud)
pax*_*blo 69
确保将您LD_LIBRARY_PATH的设置包含在要搜索的所有目录中,然后再次进行测试.
您可以使用以下命令快速测试:
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib ffmpeg
Run Code Online (Sandbox Code Playgroud)
这将仅为该调用设置它.
或者,您可以编辑/etc/ld.so.conf包含搜索的默认目录的内容.某些Linux发行版可能不包含/usr/local/lib在该文件中.
请注意,您可能还需要/etc/ld.so.cache通过运行ldconfig(以root或with sudo)来更新缓存.
Bor*_*kov 13
来自http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html:
GNU标准建议在分发源代码时默认安装/ usr/local/lib中的所有库(并且所有命令都应该进入/ usr/local/bin).
...
要搜索的目录列表存储在文件/etc/ld.so.conf中.许多Red Hat派生的发行版通常不包含文件/etc/ld.so.conf中的/ usr/local/lib.我认为这是一个错误,将/ usr/local/lib添加到/etc/ld.so.conf是在Red Hat派生系统上运行许多程序所需的常见"修复".
在Debian中/etc/ld.so.conf包含include /etc/ld.so.conf.d/*.conf,/etc/ld.so.conf.d/libc.conf包含
# libc default configuration
/usr/local/lib
Run Code Online (Sandbox Code Playgroud)
Dig*_*oss 12
程序有一个编译(ok,"链接")的想法,可以找到它们的库.如果程序期望找到它的lib,/usr/local/lib那么它将会.
还有一个名为的程序ldconfig和一个名为的配置文件/etc/ld.so.conf,很可能是一个/etc/ld.so.conf.d,它们用于指定特定于站点的目录.
阅读"man ld.so",其中列出了环境变量等其他旋钮LD_LIBRARY_PATH.
LD.SO(8) Linux Programmer’s Manual LD.SO(8)
NAME
ld.so, ld-linux.so* - dynamic linker/loader
DESCRIPTION
The programs ld.so and ld-linux.so* find and load the shared libraries
needed by a program, prepare the program to run, and then run it.
. . .
Run Code Online (Sandbox Code Playgroud)
...和...
LDCONFIG(8) Linux Programmer’s Manual LDCONFIG(8)
NAME
/sbin/ldconfig - configure dynamic linker run time bindings
SYNOPSIS
/sbin/ldconfig [ -nNvXV ] [ -f conf ] [ -C cache ] [ -r root ] direc-
tory ...
/sbin/ldconfig -l [ -v ] library ...
/sbin/ldconfig -p
DESCRIPTION
ldconfig creates the necessary links and cache to the most recent
shared libraries found in the directories specified on the command
line, in the file /etc/ld.so.conf, and in the trusted directories (/lib
and /usr/lib). The cache is used by the run-time linker, ld.so or ld-
linux.so. ldconfig checks the header and filenames of the libraries it
encounters when determining which versions should have their links
updated.
. . .
Run Code Online (Sandbox Code Playgroud)
小智 8
find / -name 'libavdevice.so.*' 找出这个图书馆是否可用.
sudo gedit /etc/ld.so.conf
添加这些行并保存:
include /usr/local/lib
include /usr
Run Code Online (Sandbox Code Playgroud)
ldconfig
IIRC,ld.so使用文件/etc/ld.so.conf列出要搜索共享对象的目录.您也可以使用环境变量LD_LIBRARY_PATH.
Linux上的ELF头文件也可能包含RPATH条目.检查RPATH条目运行
readelf -d ffmpeg | grep RPATH
Run Code Online (Sandbox Code Playgroud)
你可能不会得到任何结果.在编译时设置RPATH:
gcc ... -wl, -rpath=MY_PATH
Run Code Online (Sandbox Code Playgroud)
如果要使用执行目录 \$ORIGIN
某些程序(如chrpath)允许您编辑现有二进制文件的RPATH.
注意:任何setuid程序都不会使用,LD_LIBRARY_PATH因为它存在安全风险.
这个老问题的另一个选择是使用 LD_RUN_PATH。
export LD_RUN_PATH=/usr/local/lib
Run Code Online (Sandbox Code Playgroud)
然后再次编译:
make
make install
ldconfig
Run Code Online (Sandbox Code Playgroud)
比使用 LD_LIBRARY_PATH 更好。来自@cweiske linuxmafia.com/faq/Admin/ld-lib-path.html 的原始参考