编译使用Boost的简单c ++项目时出错

时间:2016-01-08 08:16:22

标签: c++ cmake include mingw clion

我最近从VS迁移,因为我需要跨平台支持,所以我现在使用CLion。我正在尝试在我的项目中包含boost,我认为我的CMakeLists没问题,因为它确实识别了boost,但是,在编译时我遇到了以下错误:

"C:\Program Files (x86)\JetBrains\CLion 1.2.4\bin\cmake\bin\cmake.exe" --build C:\Users\ACA\.CLion12\system\cmake\generated\4089c2c\4089c2c\Release --target ProjectACA -- -j 4
[ 50%] Building CXX object CMakeFiles/ProjectACA.dir/Main.cpp.obj
In file included from c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\cmath:44:0,
                 from c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\random:38,
                 from c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_algo.h:65,
                 from c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\algorithm:62,
                 from C:/boost/include/boost-1_60/boost/core/swap.hpp:25,
                 from C:/boost/include/boost-1_60/boost/utility/swap.hpp:15,
                 from C:/boost/include/boost-1_60/boost/tuple/detail/tuple_basic.hpp:40,
                 from C:/boost/include/boost-1_60/boost/tuple/tuple.hpp:28,
                 from C:/boost/include/boost-1_60/boost/lambda/core.hpp:28,
                 from C:/boost/include/boost-1_60/boost/lambda/lambda.hpp:14,
                 from C:\Users\ACA\ClionProjects\ProjectACA\Main.cpp:1:
c:\mingw\include\math.h: In function 'float hypotf(float, float)':
c:\mingw\include\math.h:635:30: error: '_hypot' was not declared in this scope
 { return (float)(_hypot (x, y)); }
                              ^
mingw32-make.exe[3]: *** [CMakeFiles/ProjectACA.dir/Main.cpp.obj] Error 1
CMakeFiles\ProjectACA.dir\build.make:62: recipe for target 'CMakeFiles/ProjectACA.dir/Main.cpp.obj' failed
CMakeFiles\Makefile2:66: recipe for target 'CMakeFiles/ProjectACA.dir/all' failed
CMakeFiles\Makefile2:78: recipe for target 'CMakeFiles/ProjectACA.dir/rule' failed
Makefile:117: recipe for target 'ProjectACA' failed
mingw32-make.exe[2]: *** [CMakeFiles/ProjectACA.dir/all] Error 2
mingw32-make.exe[1]: *** [CMakeFiles/ProjectACA.dir/rule] Error 2
mingw32-make.exe: *** [ProjectACA] Error 2

更多信息:我安装了mingw(不是x64)并使用了64位Windows 10.然后我将boost 1.6.0安装到C:/boost/

我的CMakeLists看起来像这样:

cmake_minimum_required(VERSION 3.3)
project(Assignment3)

SET(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "C:/boost/include/boost-1_60")
SET(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "C:/boost/lib")
find_package(Boost)
include_directories(${Boost_INCLUDE_DIR})

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

set(SOURCE_FILES Main.cpp)
add_executable(Assignment3 ${SOURCE_FILES})

无论我试图包含哪些提升库,它都会产生上述错误

0 个答案:

没有答案