Error loading shared libraries of boost

ぃ、小莉子 提交于 2019-11-27 08:07:40

问题


I am working on centos. I installed boost version 1.45.0 on my system. The programs are compiled correctly but whenever I type command to see output it gives following error:

./a.out: error while loading shared libraries: libboost_thread.so.1.45.0: cannot open shared object file: No such file or directory


回答1:


How did you install the boost libraries?

The problem you're likely having is that the linker can not find the libraries, and when you built your program, you had to manually specify additional library paths to search for libraries.

A quick fix you can do is to set LD_LIBRARY_PATH to include the directory where the boost thread library is:

export LD_LIBRARY_PATH=/path/to/boost/libs:$LD_LIBRARY_PATH

./runExecutable




回答2:


In addition to the other answers, you can also set the DT_RPATH elf tag when linking your executable

-Wl,-rpath,/path/to/boost/libraries -L /path/to/boost/libraries -lboost_whatever

This way you don't have to remember to set your LD_LIBRARY_PATH if the libraries are installed in a non-standard location.




回答3:


You need to set the LD_LIBRARY_PATH environment variable to include the path to the Boost libraries (they're possibly in /usr/local/lib, etc).

In bash, this is simply

export LD_LIBRARY_PATH=/path/to/boost:$LD_LIBRARY_PATH


来源:https://stackoverflow.com/questions/4568187/error-loading-shared-libraries-of-boost

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!