问题是 cmake 在构建项目时找不到 boost-graph 库。但是,这个库已安装在系统上。大家好!我也遇到过这样的问题。我试过
问题是,在构建项目时,cmake 没有找到 boost-graph 库。但是,这个库已安装在系统上。
大家好!我遇到过这样的问题。我尝试构建一些依赖于 Boost 和 CLapack 包的项目。(我之前已经安装了这些包)我使用了这个命令:
$ cmake ../project_name/ -DCLAPACK_BASE_DIRECTORY=/home/vitalii/clapack-3.2.1-CMAKE -DCLAPACK_BUILD_DIRECTORY=/home/vitalii/clapack-3.2.1-CMAKE/BUILD
终端的输出是:
— The C compiler identification is GNU 11.4.0
— The CXX compiler identification is GNU 11.4.0
— Detecting C compiler ABI info
— Detecting C compiler ABI info - done
— Check for working C compiler: /usr/bin/cc - skipped
— Detecting C compile features
— Detecting C compile features - done
— Detecting CXX compiler ABI info
— Detecting CXX compiler ABI info - done
— Check for working CXX compiler: /usr/bin/c++ - skipped
— Detecting CXX compile features
— Detecting CXX compile features - done
CMake Error at /usr/lib/x86_64-linux-gnu/cmake/Boost-1.74.0/BoostConfig.cmake:141 (find_package):
Found package configuration file:
/usr/lib/x86_64-linux-gnu/cmake/boost_graph-1.74.0/boost_graph-config.cmake
but it set boost_graph_FOUND to FALSE so package "boost_graph" 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_graph.so.1.74.0 (shared, Boost_USE_STATIC_LIBS=ON)
* libboost_graph.a (shared runtime, Boost_USE_STATIC_RUNTIME=ON)
Call Stack (most recent call first):
/usr/lib/x86_64-linux-gnu/cmake/Boost-1.74.0/BoostConfig.cmake:258 (boost_find_component)
/usr/share/cmake-3.22/Modules/FindBoost.cmake:594 (find_package)
CMakeLists.txt:45 (find_package)
— Configuring incomplete, errors occurred!
See also "/home/vitalii/Vitalii/lab/phd/cpf/cpf_build/CMakeFiles/CMakeOutput.log".
CMakeLists.txt第42-45行内容为:
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME ON)
find_package(Boost COMPONENTS graph program_options REQUIRED)
/usr/share/cmake-3.22/Modules/FindBoost.cmake 的 587-594 行是:
if(BOOST_ROOT AND NOT Boost_ROOT)
# Honor BOOST_ROOT by setting Boost_ROOT with CMP0074 NEW behavior.
cmake_policy(PUSH)
cmake_policy(SET CMP0074 NEW)
set(Boost_ROOT "${BOOST_ROOT}")
set(_Boost_ROOT_FOR_CONFIG 1)
endif()
find_package(Boost QUIET NO_MODULE ${_boost_FIND_PACKAGE_ARGS})
/usr/lib/x86_64-linux-gnu/cmake/Boost-1.74.0/BoostConfig.cmake 的 238-262 行是:
# Find components
if("ALL" IN_LIST Boost_FIND_COMPONENTS)
# Make sure "ALL" is the only requested component.
list(LENGTH Boost_FIND_COMPONENTS __boost_find_components_count)
if(NOT ${__boost_find_components_count} EQUAL 1)
message(AUTHOR_WARNING "ALL cannot be combined with named components; the named components will be ignored.")
endif()
unset(__boost_find_components_count)
set(Boost_ALL_TARGETS Boost::headers)
boost_find_all_components()
else()
foreach(__boost_comp IN LISTS Boost_FIND_COMPONENTS)
** boost_find_component(${__boost_comp} ${Boost_FIND_REQUIRED_${__boost_comp}} 0)**
endforeach()
endif()
该命令证明boost_graph库存在于我的系统中:
$ find / -name *libboost_graph* 2> /dev/null
/home/vitalii/anaconda3/envs/my-rdkit-env/lib/libboost_graph.so.1.84.0
/home/vitalii/anaconda3/envs/my-rdkit-env/lib/libboost_graph.so
/home/vitalii/anaconda3/envs/AmberTools23/lib/libboost_graph.so.1.82.0
/home/vitalii/anaconda3/envs/AmberTools23/lib/libboost_graph.so
/home/vitalii/anaconda3/envs/AmberTools23/lib/cmake/boost_graph-1.82.0/libboost_graph-variant-shared.cmake
/home/vitalii/anaconda3/pkgs/libboost-devel-1.82.0-h00ab1b0_6/lib/cmake/boost_graph-1.82.0/libboost_graph-variant-shared.cmake
/home/vitalii/anaconda3/pkgs/boost-cpp-1.78.0-h2c5509c_4/lib/libboost_graph.so
/home/vitalii/anaconda3/pkgs/boost-cpp-1.78.0-h2c5509c_4/lib/libboost_graph.so.1.78.0
/home/vitalii/anaconda3/pkgs/boost-cpp-1.78.0-h2c5509c_4/lib/cmake/boost_graph-1.78.0/libboost_graph-variant-shared.cmake
/home/vitalii/anaconda3/pkgs/libboost-1.84.0-hba137d9_3/lib/libboost_graph.so.1.84.0
/home/vitalii/anaconda3/pkgs/libboost-1.84.0-hba137d9_3/lib/libboost_graph.so
/home/vitalii/anaconda3/pkgs/libboost-1.82.0-h6fcfa73_6/lib/libboost_graph.so.1.82.0
/home/vitalii/anaconda3/pkgs/libboost-1.82.0-h6fcfa73_6/lib/libboost_graph.so
/home/vitalii/anaconda3/pkgs/boost-cpp-1.78.0-h6582d0a_3/lib/libboost_graph.so
/home/vitalii/anaconda3/pkgs/boost-cpp-1.78.0-h6582d0a_3/lib/libboost_graph.so.1.78.0
/home/vitalii/anaconda3/pkgs/boost-cpp-1.78.0-h6582d0a_3/lib/cmake/boost_graph-1.78.0/libboost_graph-variant-shared.cmake
/usr/lib/x86_64-linux-gnu/libboost_graph.so.1.74.0
/usr/lib/x86_64-linux-gnu/libboost_graph_parallel.so.1.74.0
/usr/lib/x86_64-linux-gnu/libboost_graph.so
/usr/lib/x86_64-linux-gnu/libboost_graph_parallel.so
/usr/lib/x86_64-linux-gnu/libboost_graph_parallel.a
/usr/lib/x86_64-linux-gnu/cmake/boost_graph-1.74.0/libboost_graph-variant-static.cmake
/usr/lib/x86_64-linux-gnu/cmake/boost_graph-1.74.0/libboost_graph-variant-shared.cmake
/usr/lib/x86_64-linux-gnu/cmake/boost_graph_parallel-1.74.0/libboost_graph_parallel-variant-static.cmake
/usr/lib/x86_64-linux-gnu/cmake/boost_graph_parallel-1.74.0/libboost_graph_parallel-variant-shared.cmake
/usr/lib/x86_64-linux-gnu/libboost_graph.a
我也阅读了一些相关问题的答案。我尝试 cmake
使用选项 -DBoost_DEBUG=TRUE
来获取更多信息,因为这些答案中的一些用户推荐了它:
$ cmake ../project_name/ -DCLAPACK_BASE_DIRECTORY=/home/vitalii/clapack-3.2.1-CMAKE -DCLAPACK_BUILD_DIRECTORY=/home/vitalii/clapack-3.2.1-CMAKE/BUILD -DBoost_DEBUG=TRUE
— Found Boost 1.74.0 at /usr/lib/x86_64-linux-gnu/cmake/Boost-1.74.0
— Requested configuration: QUIET REQUIRED COMPONENTS graph;program_options
— BoostConfig: find_package(boost_headers 1.74.0 EXACT CONFIG REQUIRED QUIET HINTS /usr/lib/x86_64-linux-gnu/cmake)
— Found boost_headers 1.74.0 at /usr/lib/x86_64-linux-gnu/cmake/boost_headers-1.74.0
— BoostConfig: find_package(boost_graph 1.74.0 EXACT CONFIG REQUIRED QUIET HINTS /usr/lib/x86_64-linux-gnu/cmake)
— Found boost_graph 1.74.0 at /usr/lib/x86_64-linux-gnu/cmake/boost_graph-1.74.0
— Boost toolset is gcc11 (GNU 11.4.0)
— Scanning /usr/lib/x86_64-linux-gnu/cmake/boost_graph-1.74.0/libboost_graph-variant*.cmake
— Including /usr/lib/x86_64-linux-gnu/cmake/boost_graph-1.74.0/libboost_graph-variant-shared.cmake
— [ ] libboost_graph.so.1.74.0
— Including /usr/lib/x86_64-linux-gnu/cmake/boost_graph-1.74.0/libboost_graph-variant-static.cmake
— [ ] libboost_graph.a
CMake Error at /usr/lib/x86_64-linux-gnu/cmake/Boost-1.74.0/BoostConfig.cmake:141 (find_package):
Found package configuration file:
/usr/lib/x86_64-linux-gnu/cmake/boost_graph-1.74.0/boost_graph-config.cmake
but it set boost_graph_FOUND to FALSE so package "boost_graph" 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_graph.so.1.74.0 (shared, Boost_USE_STATIC_LIBS=ON)
* libboost_graph.a (shared runtime, Boost_USE_STATIC_RUNTIME=ON)
Call Stack (most recent call first):
/usr/lib/x86_64-linux-gnu/cmake/Boost-1.74.0/BoostConfig.cmake:258 (boost_find_component)
/usr/share/cmake-3.22/Modules/FindBoost.cmake:594
22:55
(find_package)
CMakeLists.txt:45 (find_package)
— Configuring incomplete, errors occurred!
See also "/home/vitalii/Vitalii/lab/phd/cpf/cpf_build/CMakeFiles/CMakeOutput.log".
不幸的是,我还不知道如何解决这个问题。你有什么建议吗?
我的操作系统是 22.04.1-Ubuntu。