是否在 /usr/local/lib 中搜索共享库?
是否在 /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 ~]$
Is /usr/local/lib
searched for shared libraries ? I have this error:
[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 ~]$
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
确保您的
LD_LIBRARY_PATH
设置为包含您要搜索的所有目录,然后再次测试。您可以使用以下命令快速测试:
这将仅为该调用设置它。
或者,您可以编辑
/etc/ld.so.conf
,其中包含搜索的默认目录。某些 Linux 发行版可能不会在该文件中包含/usr/local/lib
。请注意,您可能还需要通过运行
ldconfig
(以 root 身份或使用sudo
)来更新缓存/etc/ld.so.cache
。Make sure your
LD_LIBRARY_PATH
is set up to include all directories you want to search and then test it again.You can test this quickly with:
which will set it only for that invocation.
Alternatively, you can edit
/etc/ld.so.conf
which contains the default directories searched. Some Linux distributions may not include/usr/local/lib
in that file.Note that you may also need to update the cache
/etc/ld.so.cache
by runningldconfig
(as root, or withsudo
).来自 http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html :
...
在 Debian 上,
/etc/ld.so.conf
包含include /etc/ld.so.conf.d/*.conf
和/etc/ld。 so.conf.d/libc.conf
包含From http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html:
...
On Debian
/etc/ld.so.conf
containsinclude /etc/ld.so.conf.d/*.conf
, and/etc/ld.so.conf.d/libc.conf
contains是和否
程序有一个编译(好的,“链接”)想法,知道在哪里可以找到它们的库。如果程序希望在
/usr/local/lib
中找到其库,那么它就会找到。还有一个名为
ldconfig
的程序和一个名为/etc/ld.so.conf
的配置文件,很可能是/etc/ld.so.conf。 d
,这些用于指定特定于站点的目录。阅读“man ld.so”,其中列出了其他旋钮,例如环境变量
LD_LIBRARY_PATH
。...和...
Yes and no
Programs have a compiled-in (ok, "linked-in") idea of where their libraries are to be found. If a program is expecting to find its lib in
/usr/local/lib
then it will.There is also a program called
ldconfig
and a configuration file called/etc/ld.so.conf
and most likely an/etc/ld.so.conf.d
, and these are used to specify site-specific directories.Read "man ld.so" which lists other knobs like the environment variable
LD_LIBRARY_PATH
....and...
find / -name 'libavdevice.so.*'
以查明此库是否可用。sudo gedit /etc/ld.so.conf
添加以下行并保存:
ldconfig
find / -name 'libavdevice.so.*'
to find out whether this library is available.sudo gedit /etc/ld.so.conf
Add these lines and save:
ldconfig
IIRC,ld.so 使用文件 /etc/ld.so.conf 列出搜索共享对象的目录。您还可以使用环境变量
LD_LIBRARY_PATH
。Linux 上的 ELF 标头也可能包含 RPATH 条目。要检查 RPATH 条目,请运行
您可能不会得到任何结果。要在编译时设置 RPATH,请执行以下操作:
如果您想要执行目录,请使用
\$ORIGIN
某些程序(例如 chrpath)允许您编辑现有二进制文件的 RPATH。
注意:任何 setuid 的程序都不会使用 LD_LIBRARY_PATH ,因为它存在安全风险。
IIRC, ld.so uses the file /etc/ld.so.conf to list the directories to search for shared objects. You may also use the environment variable
LD_LIBRARY_PATH
.ELF headers on linux may also contain an RPATH entry. To check the RPATH entry run
You will probably not get any result from this. To set the RPATH while compiling do:
If you want the execution directory use
\$ORIGIN
Some programs, such as chrpath, allow you to edit the RPATH of an existing binary.
NOTE: Any program that is setuid will not use
LD_LIBRARY_PATH
as it is a security risk.这个老问题的另一个选择是使用 LD_RUN_PATH。
然后再次编译:
比使用LD_LIBRARY_PATH更好。原始参考来自 @cweiske linuxmafia.com/faq/Admin/ld-lib-path。 html
Another option for this old question is to use LD_RUN_PATH.
Then compile again:
Better than using LD_LIBRARY_PATH. Original reference from @cweiske linuxmafia.com/faq/Admin/ld-lib-path.html