mingw boost库不工作

时间:2017-04-18 16:24:53

标签: boost cmake mingw clion

我正在尝试使用CMake使boost库工作,但我收到一些奇怪的错误消息。 我正在使用Stephan T. Lavavej的mingw版本,它带有boost-library。

我的CMake文件如下所示:

   cmake_minimum_required(VERSION 3.6)
project(untitled)

set(Boost_INCLUDE_DIR C:/MinGW/include)
set(Boost_LIBRARY_DIR C:/MinGW/lib)
find_package(Boost COMPONENTS system filesystem REQUIRED)
include_directories(${Boost_INCLUDE_DIR})



set(CMAKE_CXX_FLAGS "-Ofast -msse -msse2 -msse3  -march=znver1 -fno-use-linker-plugin -flto")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -static-libstdc++ ")

set(SOURCE_FILES main.cpp HexBoard.cpp HexBoard.h TreeNode.cpp TreeNode.h)
add_executable(untitled ${SOURCE_FILES})

我收到以下错误消息:

> CMake Warning at C:/Program Files (x86)/JetBrains/CLion
> 2016.3.5/bin/cmake/share/cmake-3.6/Modules/FindBoost.cmake:743 (message):   Imported targets not available for Boost version 106300
> Call Stack (most recent call first):   C:/Program Files
> (x86)/JetBrains/CLion
> 2016.3.5/bin/cmake/share/cmake-3.6/Modules/FindBoost.cmake:842 (_Boost_COMPONENT_DEPENDENCIES)   C:/Program Files
> (x86)/JetBrains/CLion
> 2016.3.5/bin/cmake/share/cmake-3.6/Modules/FindBoost.cmake:1395 (_Boost_MISSING_DEPENDENCIES)   CMakeLists.txt:6 (find_package)
> 
> 
> CMake Warning at C:/Program Files (x86)/JetBrains/CLion
> 2016.3.5/bin/cmake/share/cmake-3.6/Modules/FindBoost.cmake:743 (message):   Imported targets not available for Boost version 106300
> Call Stack (most recent call first):   C:/Program Files
> (x86)/JetBrains/CLion
> 2016.3.5/bin/cmake/share/cmake-3.6/Modules/FindBoost.cmake:842 (_Boost_COMPONENT_DEPENDENCIES)   C:/Program Files
> (x86)/JetBrains/CLion
> 2016.3.5/bin/cmake/share/cmake-3.6/Modules/FindBoost.cmake:1395 (_Boost_MISSING_DEPENDENCIES)   CMakeLists.txt:6 (find_package)

如何使增强库在mingw64下工作?

非常感谢任何帮助

1 个答案:

答案 0 :(得分:1)

我使用相同的设置,我的制作文件看起来像你的。

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") 

set(Boost_INCLUDE_DIR c:/mingw/include/)
set(Boost_LIBRARY_DIR c:/mingw/lib/)
find_package(Boost COMPONENTS system filesystem REQUIRED)
include_directories(${Boost_INCLUDE_DIR})

我还将MINGW路径添加到我的系统环境用户变量中。 enter image description here