4
votes

I am trying to use filesystem from boost in c++

It seems the compilation is ok when using

"c++ -c Analyse.c -o Analyse.o -g -W -Wall -L/usr/local/lib -lboost_filesystem -lboost_system"

However I have the following error when trying to execute my code :

"error while loading shared libraries: libboost_filesystem.so.1.54.0: cannot open shared object file: No such file or directory", a find / -iname "libboost_system.so.1.54.0

I had some issues to install boost (I first installed the 1.49 and after that 1.54) so I was wondering if there could be any conflict between the 2 version ?

P.S : btw a "find / -iname "libboost_system.so.1.54.0" gave me the following

/usr/include/boost/boost_1_54_0/bin.v2/libs/system/build/gcc-4.7/release/threading-multi/libboost_system.so.1.54.0

/usr/local/lib/libboost_system.so.1.54.0
2
When I link boost libraries I usually link libraries path only i.e. /usr/local/lib. I don't specify libraries names. BTW boost 1.49 and boost 1.54 should be in seperated folders.LukeCodeBaker

2 Answers

4
votes

Try to add the directory before execution. For example: LD_LIBRARY_PATH="/usr/local/lib/" ./Analyse.o

0
votes

I encountered this issue very recently, after a fresh installation of boost. In my case, the solution was to simply run

sudo ldconfig

The explanation is that the system keeps a cache of the installed shared libraries (located in /usr/lib, /lib, /usr/local/lib). When the libraries are changed, or new ones are added, the cache is not updated until ldconfig is run. More details can be found in the ldconfig manual.