In a nutshell...
C++ program (using the boost libraries) compiles fine in Eclipse, but then “error while loading shared libraries: libboost_thread.so.1.46.1: cannot open shared object file: No such file or directory” it shown when running it.
Details
I am running a basic program on C++ to check that I can use the boost threading libraries correctly.
#include <boost/thread/thread.hpp>
#include <iostream>
void hello ()
{
Std::cout<<”Hello, I am a thread”<<std::endl;
}
int main ()
{
boost::thread th1(&hello);
th1.join();
}
The code compiles fine, so I believed that I had installed and set up the boost libraries correctly (added directories to include etc)
However when I try to run the program I get the following error message in the consol
error while loading shared libraries: libboost_thread.so.1.46.1: cannot open shared object file: No such file or directory
I had a very similar issue with FreeFileSYnc, compiles fine but won't launch due to a libboost thread error :
To fix it I did :
It may help other people.
boost thread is a dynamic library. It must be found at runtime for the program to run (like a DLL in Windows).
Have you checked if the
libboost_thread.so.1.46.1
is present atLD_LIBRARY_PATH
?Copy the library at your
LD_LIBRARY_PATH
, this path is searched for dynamic libraries(so) at runtime.A bit late to the party, but hassled all day with the same problem. I recently installed the latest
boost 1_51_0
locally into my$HOME/bin/boost_1_51_0
. What worked for me, was to export the include and library path by adding these lines to my.bash_rc
:Then add the include path and lib path to your
Makefile
:Then you can add the libs from
1_51
viaI had the same problem, and
ldconfig
did not fix it.If you, as I did, installed the boost libraries using a plain
bjam
command, chances are you installed the libraries in a stage subfolder. See this page as a reference. What worked for me was to run the following: