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


当前回答

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

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

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

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

其他回答

我得到了这个错误,我想这和你的原因一样

error while loading shared libraries: libnw.so: cannot open shared object 
file: No such file or directory

试试这个。修复文件权限:

sudo su
cd /opt/Popcorn (or wherever it is) 
chmod -R 555 * (755 if not ok) 
chown -R root:root *

您的库是一个动态库。 您需要告诉操作系统在运行时可以在哪里定位它。

为了做到这一点, 我们需要做这些简单的步骤:

Find where the library is placed if you don't know it. sudo find / -name the_name_of_the_file.so Check for the existence of the dynamic library path environment variable(LD_LIBRARY_PATH) echo $LD_LIBRARY_PATH If there is nothing to be displayed, add a default path value (or not if you wish to) LD_LIBRARY_PATH=/usr/local/lib We add the desired path, export it and try the application. Note that the path should be the directory where the path.so.something is. So if path.so.something is in /my_library/path.so.something, it should be: LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/my_library/ export LD_LIBRARY_PATH ./my_app

引用来源

您需要确保在期间指定了库路径 当你编译你的。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。

在这里可以找到一个类似的问题。 我尝试过上面提到的解决方案,它确实有效。

前面几个问题的答案可能有用。但下面是一个简单的方法来解决它。 它通过重新安装libwbclient包来工作 在fedora:

dnf reinstall libwbclient

你可以在这里阅读有关图书馆的内容: https://domiyanyue.medium.com/c-development-tutorial-4-static-and-dynamic-libraries-7b537656163e