找不到 "boost_json" 提供的软件包配置文件



当遵循此链接设置json解析boost时,我无法找到boost json组件。

链接:在cmake

中使用boost::json静态库这是我的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 1.75.0
2020年12月11日19:50 GMT

New Libraries: JSON,叶子,pfr。更新库:Asio, Atomic, Beast, Container, Endian, Filesystem, GIL, Histogram, Interprocess, Intrusive, Log, Move, Mp11, Optional, Outcome, Polygon, Preprocessor, Rational, Signal2, System, uBLAS, VMD, Wave.

最新更新