且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

加载共享库时出现Linux错误:无法打开共享对象文件:没有这样的文件或目录

更新时间:2021-12-13 07:56:31

更新
虽然我在下面写的是关于共享库的一般答案,但我认为这类消息的最常见原因是因为您已经安装了一个软件包,但没有安装该软件包的"-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.