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
Edit: OK I didn't notice the .1 at the end was part of the filename. What does that mean anyway?
I had this error when running my application with Eclipse CDT on Linux x86.
To fix this:
Set the path
The error occurs as the system cannot refer to the library file mentioned. Take the following steps:
locate libpthread_rt.so.1
will list the path of all the files with that name. Let's suppose a path is/home/user/loc
.cd home/USERNAME
. Replace USERNAME with the name of the current active user with which you want to run the file.vi .bash_profile
and at the end of theLD_LIBRARY_PATH
parameter, just before.
, add the line/lib://home/usr/loc:.
. Save the file.You need to ensure that you specify the library path during linking when you compile your .c file:
The -Wl,-R part tells the resulting binary to also look for library in /usr/local/lib at runtime before trying to use the one in /usr/lib/
Hope it will help you.
I got this error and I think its the same reason of yours
Try this. Fix permissions on files:
Here are a few solutions you can try:
ldconfig
As AbiusX pointed out: If you have just now installed the library, you may simply need to run ldconfig.
Usually your package manager will take care of this when you install a new library, but not always, and it won't hurt to run ldconfig even if that is not your issue.
Dev package or wrong version
If that doesn't work, I would also check out Paul's suggestion and look for a "-dev" version of the library. Many libraries are split into dev and non-dev packages. You can use this command to look for it:
This can also help if you simply have the wrong version of the library installed. Some libraries are published in different versions simultaneously, for example, Python.
Library location
If you are sure that the right package is installed, and ldconfig didn't find it, it may just be in a nonstandard directory. By default, ldconfig looks in
/lib
,/usr/lib
, and directories listed in/etc/ld.so.conf
and$LD_LIBRARY_PATH
. If your library is somewhere else, you can either add the directory on its own line in/etc/ld.so.conf
, append the library's path to$LD_LIBRARY_PATH
, or move the library into/usr/lib
. Then runldconfig
.To find out where the library is, try this:
(Replace
libraryname
with the name of your library)If you go the
$LD_LIBRARY_PATH
route, you'll want to put that into your~/.bashrc
file so it will run every time you log in: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.
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 provideslibpthread_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 http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html.
In your case, you might get away with symlinking
libpthread_rt.so.1
tolibpthread_rt.so
. No guarantees that it won't break your code and eat your TV dinners, though.