1

I have the problem that I can build an executable that is linked to libboost, but when I execute the executable I will get the error that the library is not found.

The boost library is build manual on the computer and linked to the executable.

When executing the executable I will get the error:

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

Even when I place the compiler boost library next to the executable, it does not work.

The application is built with the following g++ command:

g++ -o executable -O2 -I /root/filters/boost/boost/ -I /usr/include/mysql/ -lmysqlcppconn -lboost_regex -lmysqlclient -lpthread  -L/root/filters/boost/boost/stage/lib/  -std=c++11  *.cpp
Laurence
  • 1,815
  • 4
  • 22
  • 35
  • 1
    If you're on linux, do something like LD_LIBRARY_PATH=/root/filters/boost/boost/stage/lib/ and then run your code – Moshe Gottlieb May 11 '17 at 12:31
  • @iMoses I still get the same error – Laurence May 11 '17 at 12:31
  • 1
    @Laurence you need to use the right path, to where the boost libraries are, not just copy exactly what iMoses said. If you do that (and remember to `export` the environment variable so the child process actually sees it) then it will work. If it doesn't work it's because you did it wrong. – Jonathan Wakely May 11 '17 at 12:42
  • 1
    @Laurence use `LD_LIBRARY_PATH=... command` or `export LD_LIBRARY_PATH` – sehe May 11 '17 at 12:42
  • 1
    @JonathanWakely iMoses copied the path from the question :) – sehe May 11 '17 at 12:42
  • @sehe oh yeah, I thought the "stage/lib" part was a guess. Then the problem is not exporting it. – Jonathan Wakely May 11 '17 at 12:43
  • http://stackoverflow.com/questions/9412296/ld-library-path-the-shared-lib-path-in-linux and http://stackoverflow.com/questions/695530/why-do-i-have-to-define-ld-library-path-with-an-export-every-time-i-run-my-appli – Jonathan Wakely May 11 '17 at 12:44

0 Answers0