加载共享库时出现 Linux 错误:无法打开共享对象文件:没有这样的文件或目录 [英] Linux error while loading shared libraries: cannot open shared object file: No such file or directory

查看:47
本文介绍了加载共享库时出现 Linux 错误:无法打开共享对象文件:没有这样的文件或目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

程序是 Xenomai 测试套件的一部分,从 Linux PC 交叉编译成 Linux+Xenomai ARM 工具链.

Program is part of the Xenomai test suite, cross-compiled from Linux PC into Linux+Xenomai ARM toolchain.

# echo $LD_LIBRARY_PATH                                                                                                                                          
/lib                                                                                                                                                             
# ls /lib                                                                                                                                                        
ld-2.3.3.so         libdl-2.3.3.so      libpthread-0.10.so                                                                                                       
ld-linux.so.2       libdl.so.2          libpthread.so.0                                                                                                          
libc-2.3.3.so       libgcc_s.so         libpthread_rt.so                                                                                                         
libc.so.6           libgcc_s.so.1       libstdc++.so.6                                                                                                           
libcrypt-2.3.3.so   libm-2.3.3.so       libstdc++.so.6.0.9                                                                                                       
libcrypt.so.1       libm.so.6                                                                                                                                    
# ./clocktest                                                                                                                                                    
./clocktest: error while loading shared libraries: libpthread_rt.so.1: cannot open shared object file: No such file or directory                                 

好吧,我没有注意到末尾的 .1 是文件名的一部分.这到底是什么意思?

OK I didn't notice the .1 at the end was part of the filename. What does that mean anyway?

推荐答案

更新
虽然我在下面写的是关于共享库的一般答案,但我认为这些消息的最常见原因是因为您已经安装了一个包,但没有安装 -dev 版本的那个包裹.

好吧,这不是在说谎 - 该列表中没有 libpthread_rt.so.1.您可能需要重新配置并重新构建它,使其依赖于您拥有的库,或者安装任何提供 libpthread_rt.so.1 的东西.

Well, it's not lying - there is no libpthread_rt.so.1 in that listing. You probably need to re-configure and re-build it so that it depends on the library you have, or install whatever provides libpthread_rt.so.1.

一般来说,.so 后面的数字是版本号,你经常会发现它们是相互的符号链接,所以如果你有 libfoo.so 的 1.1 版本,你就会有一个真正的文件 libfoo.so.1.0,以及指向 libfoo.so.1.0 的符号链接 foo.so 和 foo.so.1.如果您安装 1.1 版本而不删除另一个版本,您将拥有一个 libfoo.so.1.1,并且 libfoo.so.1 和 libfoo.so 现在将指向新版本,但任何需要该确切版本的代码都可以使用 libfoo.so.1.0 文件.仅依赖版本 1 API,但不关心它是 1.0 还是 1.1 的代码将指定 libfoo.so.1.正如 orip 在评论中指出的那样,这很好解释 此处.

Generally, the numbers after the .so are version numbers, and you'll often find that they are symlinks to each other, so if you have version 1.1 of libfoo.so, you'll have a real file libfoo.so.1.0, and symlinks foo.so and foo.so.1 pointing to the libfoo.so.1.0. And if you install version 1.1 without removing the other one, you'll have a libfoo.so.1.1, and libfoo.so.1 and libfoo.so will now point to the new one, but any code that requires that exact version can use the libfoo.so.1.0 file. Code that just relies on the version 1 API, but doesn't care if it's 1.0 or 1.1 will specify libfoo.so.1. As orip pointed out in the comments, this is explained well at here.

在您的情况下,您可能libpthread_rt.so.1 符号链接到libpthread_rt.so.但是,不能保证它不会破坏您的代码并吃掉您的电视晚餐.

In your case, you might get away with symlinking libpthread_rt.so.1 to libpthread_rt.so. No guarantees that it won't break your code and eat your TV dinners, though.

这篇关于加载共享库时出现 Linux 错误:无法打开共享对象文件:没有这样的文件或目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆