gpt4 book ai didi

C++ Cmake boost lib不断抛出很多错误

转载 作者:太空宇宙 更新时间:2023-11-04 12:45:09 26 4
gpt4 key购买 nike

我正在尝试使用 cmake 在 boost 中做一个应用程序。我不知道为什么,但它不断抛出很多错误。我正在使用 cmake 3.10,boost 1.68。

错误日志太长,所以我把它贴在这里:

https://pastebin.com/E91KHfpD

我的 cmake 配置:

    cmake_minimum_required(VERSION 3.10)
project(testProject)

set(CMAKE_CXX_STANDARD 11)

add_executable(testProject main.cpp)
set_target_properties(testProject PROPERTIES COMPILE_FLAGS "-m32" LINK_FLAGS "-m32")
target_link_libraries(testProject F:/c++libs/boost_1_68_0/stage/lib/libboost_filesystem-mgw51-mt-s-x32-1_68.a)
target_include_directories(testProject PRIVATE F:/c++libs/boost_1_68_0)

其次认为我正在尝试使用 findboost。我的第二个 cmake 配置:

cmake_minimum_required(VERSION 3.12.1)
project(testProject)

set(CMAKE_CXX_STANDARD 11)

set(BOOST_ROOT "F:/c++libs/boost_1_68_0")
set(BOOST_LIBRARYDIR ${BOOST_ROOT}/stage/lib/)
set(BOOST_INCLUDEDIR "F:/c++libs/boost_1_68_0/boost")
set(Boost_USE_STATIC_LIBS ON)
set(Boost_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME ON)
add_definitions(-DBOOST_ERROR_CODE_HEADER_ONLY)

find_package(Boost 1.68 COMPONENTS system filesystem REQUIRED)

add_executable(testProject main.cpp)
target_link_libraries(testProject ${Boost_LIBRARIES})
target_include_directories(testProject PRIVATE ${Boost_INCLUDE_DIRS})
set_target_properties(testProject PROPERTIES COMPILE_FLAGS "-m32" LINK_FLAGS "-m32")

这会抛出这个错误:

F:/c++libs/boost_1_68_0/stage/lib/libboost_filesystem-mgw51-mt-sd-1_68.a(codecvt_error_category.o): duplicate section `.rdata$_ZTIN5boost6system14error_category12std_categoryE[__ZTIN5boost6system14error_category12std_categoryE]' has different size
F:/c++libs/boost_1_68_0/stage/lib/libboost_filesystem-mgw51-mt-sd-1_68.a(codecvt_error_category.o): duplicate section `.rdata$_ZTVN5boost6system14error_category12std_categoryE[__ZTVN5boost6system14error_category12std_categoryE]' has different size

最佳答案

您不能使用 -DBOOST_ERROR_CODE_HEADER_ONLY 并链接到 boost_system,您需要删除定义或库。

关于C++ Cmake boost lib不断抛出很多错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52028040/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com