cmake时提示Could not find the following Boost libraries: boost_system boost_iostreams

一个项目的用到了boost库,然而在编译时报错:

CMake Error at /usr/share/cmake-3.5/Modules/FindBoost.cmake:1677 (message):
  Unable to find the requested Boost libraries.

  Boost version: 1.65.1

  Boost include path: /usr/include

  Could not find the following Boost libraries:

          boost_system
          boost_iostreams

  No Boost libraries were found.  You may need to set BOOST_LIBRARYDIR to the
  directory containing Boost libraries or BOOST_ROOT to the location of
  Boost.

我明明装了boost库啊,怎么找不到呢,于是用 locate boost_system命令查看,得到:

/usr/lib/x86_64-linux-gnu/libboost_system.so.1.58.0

说吗这个库确实有,只是cmakelists没找到。为啥它找不到呢?因为它找的是libboost_system.so文件,给它加个1.58.0它就找不到了。不过好办,我们建立个软链接:

cd /usr/lib/x86_64-linux-gnu/
sudo ln -s libboost_system.so.1.58.0  libboost_system.so
sudo ln -s libboost_iostreams.so.1.58.0  libboost_iostreams.so

就大功告成啦

猜你喜欢

转载自blog.csdn.net/a735148617/article/details/107013348