找不到 "boost_json" 提供的包配置文件
Could not find a package configuration file provided by "boost_json"
在按照此 link 为 json 解析设置提升时,我无法找到提升 json 组件。
Link:
Using boost::json static library with cmake
这是我的 CMakeLists.txt
:
cmake_minimum_required(VERSION 3.9)
set (CMAKE_CXX_STANDARD 14)
set( Boost_USE_STATIC_LIBS ON )
#set( Boost_USE_MULTITHREADED ON )
#set( Boost_USE_STATIC_RUNTIME OFF )
find_package( Boost REQUIRED COMPONENTS json )
if ( Boost_FOUND )
include_directories( ${Boost_INCLUDE_DIRS} )
else()
message( FATAL_ERROR "Required Boost packages not found. Perhaps add -DBOOST_ROOT?" )
endif()
add_executable (test main.cc)
target_include_directories(test PUBLIC ${Boost_INCLUDE_DIRS})
target_link_libraries(test PUBLIC Boost::boost
Boost::json)
错误:
CMake Error at /usr/lib/x86_64-linux-gnu/cmake/Boost-1.71.0/BoostConfig.cmake:117 (find_package):
Could not find a package configuration file provided by "boost_json"
(requested version 1.71.0) with any of the following names:
boost_jsonConfig.cmake
boost_json-config.cmake
Add the installation prefix of "boost_json" to CMAKE_PREFIX_PATH or set
"boost_json_DIR" to a directory containing one of the above files. If
"boost_json" provides a separate development package or SDK, be sure it has
been installed.
Call Stack (most recent call first):
/usr/lib/x86_64-linux-gnu/cmake/Boost-1.71.0/BoostConfig.cmake:182 (boost_find_component)
/usr/share/cmake-3.16/Modules/FindBoost.cmake:443 (find_package)
CMakeLists.txt:11 (find_package)
-- Configuring incomplete, errors occurred
如何解决此错误?我确实浏览了一些描述类似 boost 问题的帖子,但没有任何效果。
Boost JSON 是在版本 1.75.0 中引入的。它在版本 1.71.0 中不可用。您需要在系统上安装更新版本的 boost。
来自 boost version history page(强调我的):
Version 1.75.0
December 11th, 2020 19:50 GMT
New Libraries: JSON, LEAF, PFR. Updated Libraries: Asio, Atomic, Beast, Container, Endian, Filesystem, GIL, Histogram, Interprocess, Intrusive, Log, Move, Mp11, Optional, Outcome, Polygon, Preprocessor, Rational, Signal2, System, uBLAS, VMD, Wave.
在按照此 link 为 json 解析设置提升时,我无法找到提升 json 组件。
Link: Using boost::json static library with cmake
这是我的 CMakeLists.txt
:
cmake_minimum_required(VERSION 3.9)
set (CMAKE_CXX_STANDARD 14)
set( Boost_USE_STATIC_LIBS ON )
#set( Boost_USE_MULTITHREADED ON )
#set( Boost_USE_STATIC_RUNTIME OFF )
find_package( Boost REQUIRED COMPONENTS json )
if ( Boost_FOUND )
include_directories( ${Boost_INCLUDE_DIRS} )
else()
message( FATAL_ERROR "Required Boost packages not found. Perhaps add -DBOOST_ROOT?" )
endif()
add_executable (test main.cc)
target_include_directories(test PUBLIC ${Boost_INCLUDE_DIRS})
target_link_libraries(test PUBLIC Boost::boost
Boost::json)
错误:
CMake Error at /usr/lib/x86_64-linux-gnu/cmake/Boost-1.71.0/BoostConfig.cmake:117 (find_package):
Could not find a package configuration file provided by "boost_json"
(requested version 1.71.0) with any of the following names:
boost_jsonConfig.cmake
boost_json-config.cmake
Add the installation prefix of "boost_json" to CMAKE_PREFIX_PATH or set
"boost_json_DIR" to a directory containing one of the above files. If
"boost_json" provides a separate development package or SDK, be sure it has
been installed.
Call Stack (most recent call first):
/usr/lib/x86_64-linux-gnu/cmake/Boost-1.71.0/BoostConfig.cmake:182 (boost_find_component)
/usr/share/cmake-3.16/Modules/FindBoost.cmake:443 (find_package)
CMakeLists.txt:11 (find_package)
-- Configuring incomplete, errors occurred
如何解决此错误?我确实浏览了一些描述类似 boost 问题的帖子,但没有任何效果。
Boost JSON 是在版本 1.75.0 中引入的。它在版本 1.71.0 中不可用。您需要在系统上安装更新版本的 boost。
来自 boost version history page(强调我的):
Version 1.75.0
December 11th, 2020 19:50 GMTNew Libraries: JSON, LEAF, PFR. Updated Libraries: Asio, Atomic, Beast, Container, Endian, Filesystem, GIL, Histogram, Interprocess, Intrusive, Log, Move, Mp11, Optional, Outcome, Polygon, Preprocessor, Rational, Signal2, System, uBLAS, VMD, Wave.