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

查看:1011
本文介绍了加载共享库时出现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"版本.

Update
While what I write below is true as a general answer about shared libraries, I think the most frequent cause of these sorts of message is because you've installed a package, but not installed the "-dev" version of that package.

好吧,这不是在撒谎-该列表中没有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 http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html.

在您的情况下,您可能通过将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天全站免登陆