找不到“boost_json”提供的包配置文件

Vin*_*edi 2 c++ boost cmake boost-json

在按照此链接设置 boost 进行 json 解析时,我无法找到 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)
Run Code Online (Sandbox Code Playgroud)

错误:

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
Run Code Online (Sandbox Code Playgroud)

我该如何解决这个错误?我确实浏览了一些描述类似问题的帖子,但没有任何效果。

fab*_*ian 5

Boost JSON 在 1.75.0 版本中引入。它在版本 1.71.0 中不可用。您需要在系统上安装更新版本的 boost。

boost 版本历史页面(强调我的):

版本 1.75.0
2020 年 12 月 11 日 19:50 GMT

新库:JSON、LEAF、PFR。更新的库:Asio、Atomic、Beast、Container、Endian、文件系统、GIL、直方图、进程间、侵入式、Log、Move、Mp11、Optional、Outcome、Polygon、预处理器、Rational、Signal2、System、uBLAS、VMD、Wave。