boost库问题* libboost_filesystem.so.1.74.0 (shared, Boost_USE_STATIC_LIBS=ON)

编译cpp工程的时候,遇到了下面的错误:

CMake Error at /usr/lib/cmake/Boost-1.74.0/BoostConfig.cmake:141 (find_package):
  Found package configuration file:

    /usr/lib/cmake/boost_filesystem-1.74.0/boost_filesystem-config.cmake

  but it set boost_filesystem_FOUND to FALSE so package "boost_filesystem" is
  considered to be NOT FOUND.  Reason given by package:

  No suitable build variant has been found.

  The following variants have been tried and rejected:

  * libboost_filesystem.so.1.74.0 (shared, Boost_USE_STATIC_LIBS=ON)


根据提示,需要在CMakeLists.txt中手动关闭boost动态链接库,我们在CMakeLists.txt文件

find_package(Boost REQUIRED COMPONENTS filesystem)

上面添加下面两行代码:

 set(Boost_USE_STATIC_LIBS OFF)
 set(Boost_USE_STATIC_RUNTIME OFF)

编译通过。

参考链接:https://stackoverflow.com/questions/63615895/boost-chrono-found-to-false-so-package-boost-chrono-is-considered-to-be-not-fo

你可能感兴趣的:(cmake,c++,linux,boost)