本文介绍了CMake-找不到Boost(丢失:序列化)(找到的版本为"1.73.0"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在项目中使用Boost了一段时间了,尽管到目前为止,我只使用了仅标头库.现在,我想使用序列化,但是当我尝试将序列化添加为必需组件时,出现了写在标题中的错误.

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.

这是我的CMAKE文件:

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()

我已经检查了Boost文件夹,序列化位于"D:\ Program Files \ boost \ boost_1_73_0 \ libs \ serialization"

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

我尝试设置 BOOST_ROOT 和其他相关变量,但似乎没有任何效果.

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

这是加载CMake文件时产生的完整错误

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

不确定是否相关,但是我使用CLion作为我的IDE,使用mingw-w64作为我的编译器.

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

推荐答案

我最终使用了一个名为vcpkg的C ++软件包管理器来安装Boost:x64-windows,然后正确地找到了Boost和相应的组件.有关如何安装它的说明,可以在这里找到: https://github.com/Microsoft/vcpkg

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

安装后,可以使用以下命令安装64位Boost:

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

.\ vcpkg.exe安装boost:x64-windows

我仍然不知道CMake最初的问题是什么,我敢肯定有一种无需使用程序包管理器即可解决此问题的方法,但是对于那些使用程序包管理器可以的人来说,这是一个解决方案

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.

编辑

发现这仍然不能完全解决我的问题,并导致了其他问题.我找到了一个不使用包管理器的完整解决方案,并将其发布在我对以下问题的回答中:

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

这篇关于CMake-找不到Boost(丢失:序列化)(找到的版本为"1.73.0"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 00:10