我正在尝试使用cmake增强应用程序。 我不知道为什么,但是它不断抛出很多错误。我正在使用cmake 3.10,提高1.68。
错误日志太长,所以我在这里发布了它:
我的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
答案 0 :(得分:0)
您不能使用-DBOOST_ERROR_CODE_HEADER_ONLY
并链接到boost_system
,需要删除定义或库。