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

# 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是文件名的最后部分吗?这到底是什么意思?


当前回答

您需要确保在期间指定了库路径 当你编译你的。c文件时链接:

gcc -I/usr/local/include xxx.c -o xxx -L/usr/local/lib -Wl,-R/usr/local/lib

-Wl,-R部分告诉生成的二进制文件也查找库 在尝试使用/usr/lib/中的一个之前,在运行时/usr/local/lib。

其他回答

更新 虽然我下面所写的是关于共享库的一般答案,但我认为这类消息最常见的原因是因为您安装了一个包,但没有安装该包的-dev版本。


好吧,这不是撒谎——没有libpthread_rt.so。该列表中的1。您可能需要重新配置和重新构建它,以便它取决于您拥有的库,或者安装任何提供libpthread_rt.so.1的库。

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。不过,不能保证它不会破坏你的代码并吃掉你的电视晚餐。

尝试在~/中添加LD_LIBRARY_PATH,它指示搜索路径。bashrc文件(

LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path_to_your_library

它的工作原理!

由于系统无法引用提到的库文件而发生错误。采取以下步骤:

执行locate libpthread_rt.so。1将列出所有具有该名称的文件的路径。假设路径是/home/user/ loco。 拷贝路径,执行cd home/USERNAME命令。将USERNAME替换为要运行该文件的当前活动用户的名称。 运行vi .bash_profile,在LD_LIBRARY_PATH参数的末尾,就在.之前,添加一行/lib://home/usr/loc:..保存文件。 关闭终端并重新启动应用程序。它应该运行。

另一种可能的解决方案取决于您的情况。

如果你知道libpthread_rt.so。1与libpthread_rt相同。然后你可以创建一个符号链接:

ln -s /lib/libpthread_rt.so /lib/libpthread_rt.so.1

然后ls -l /lib现在应该显示符号链接及其指向的内容。

我要做的就是跑

sudo apt-get install libfontconfig1

我在位于/usr/lib/x86_64-linux-gnu的文件夹中,它工作得很好。