CMake - Could NOT find Boost (missing: serialization) (found version “1.73.0”

自古美人都是妖i 提交于 2021-02-19 05:35:46

问题


I've been using Boost with my project for a while now, though until now, I'd only used the header-only libraries. I now want to use serialization, but when I try to add serialization as a REQUIRED component, I get the error written in the title.

Here is my CMAKE file:

cmake_minimum_required(VERSION 3.15)
project(GinRummyCPP)

SET(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "D:/Program Files/boost/boost_1_73_0")
SET(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "D:/Program Files/boost/boost_1_73_0/libs")
set(CMAKE_CXX_STANDARD 17)
find_package(Boost COMPONENTS serialization)
add_executable(GinRummyCPP main.cpp)
if(Boost_FOUND)
    include_directories(${Boost_INCLUDE_DIRS})
    target_link_libraries(GinRummyCPP ${Boost_LIBRARIES})
endif()

I've checked my Boost folder, and serialization is at "D:\Program Files\boost\boost_1_73_0\libs\serialization"

I've tried setting BOOST_ROOT and other relevant variables, but nothing seems to work.

Here is the full error produced when loading the CMake file

CMake Warning at C:/Program Files/JetBrains/CLion 2019.3.2/bin/cmake/win/share/cmake-3.15/Modules/FindBoost.cmake:1144 (message):
  New Boost version may have incorrect or missing dependencies and imported
  targets
Call Stack (most recent call first):
  C:/Program Files/JetBrains/CLion 2019.3.2/bin/cmake/win/share/cmake-3.15/Modules/FindBoost.cmake:1266 (_Boost_COMPONENT_DEPENDENCIES)
  C:/Program Files/JetBrains/CLion 2019.3.2/bin/cmake/win/share/cmake-3.15/Modules/FindBoost.cmake:1904 (_Boost_MISSING_DEPENDENCIES)
  CMakeLists.txt:7 (find_package)


-- Could NOT find Boost (missing: serialization) (found version "1.73.0")
-- Configuring done
-- Generating done
-- Build files have been written to: D:/Documents/GinRummyCPP/cmake-build-release-mingw-64

Not sure if it's relevant, but I'm using CLion as my IDE and mingw-w64 as my compiler.


回答1:


I ended up using a C++ package manager called vcpkg to install Boost:x64-windows, and Boost and the appropriate components were properly found after that. The instructions for how to install it can be found here: https://github.com/Microsoft/vcpkg

After installing it, 64 bit Boost can be installed with the following command:

.\vcpkg.exe install boost:x64-windows

I still don't know what the original issue with CMake was, and I'm sure there was a way to fix it without using a package manager, but this is a solution for those that are okay with using a package manager.

EDIT

Found out this still didn't completely resolve my issue, and led to other problems. I found a complete solution that doesn't use a package manager and posted it in my answer to this question: Undefined reference errors in simple boost serialization



来源:https://stackoverflow.com/questions/61989414/cmake-could-not-find-boost-missing-serialization-found-version-1-73-0

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!