我是Cmake和Boost的新手。我现在正在使用cmake开发程序,需要帮助。
系统:Windows 7
Cmake版本:3.16.0-rc1
增强版:boost_1_71_0。通过.exe文件安装boost。
Gcc版本:4.8.1(rev5,由MinGW-W64项目构建)
Visual Studio:vs 2015
当我在cmake ..
目录中运行build
时,没有错误发生。输出为:
The C compiler identification is MSVC 19.0.24215.1
The CXX compiler identification is MSVC 19.0.24215.1
Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe
Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe -- works
Detecting C compiler ABI info
Detecting C compiler ABI info - done
Detecting C compile features
Detecting C compile features - done
Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe
Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe -- works
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Detecting CXX compile features
Detecting CXX compile features - done
Found Boost: C:/local/boost_1_71_0 (found version "1.71.0")
Boost_Found Success!
Found OpenCV: C:/Users/gph/opencv/binaries (found version "3.4.5")
Found OpenCV: C:/Users/gph/opencv/binaries (found version "3.4.5") found components: core highgui imgproc videoio
Configuring done
但是我想使用minGW进行编译,因此当我朗姆酒cmake -G "MinGW Makefiles"
时,发生错误,提示“找不到Boost(缺少:Boost_INCLUDE_DIR)”。输出为:
The C compiler identification is GNU 4.8.1
The CXX compiler identification is GNU 4.8.1
Check for working C compiler: C:/MinGW/bin/gcc.exe
Check for working C compiler: C:/MinGW/bin/gcc.exe -- works
Detecting C compiler ABI info
Detecting C compiler ABI info - done
Detecting C compile features
Detecting C compile features - done
Check for working CXX compiler: C:/MinGW/bin/g++.exe
Check for working CXX compiler: C:/MinGW/bin/g++.exe -- works
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Detecting CXX compile features
Detecting CXX compile features - done
CMake Error at C:/Users/gph/cmake/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:146 (message):
Could NOT find Boost (missing: Boost_INCLUDE_DIR)
Call Stack (most recent call first):
C:/Users/gph/cmake/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:393 (_FPHSA_FAILURE_MESSAGE)
C:/Users/gph/cmake/share/cmake-3.16/Modules/FindBoost.cmake:2162 (find_package_handle_standard_args)
CMakeLists.txt:34 (find_package)
Configuring incomplete, errors occurred!
See also "C:/Users/gph/Desktop/libvibe++/build/CMakeFiles/CMakeOutput.log".
运行cmake -G "MinGW Makefiles"
时如何解决错误?谢谢大家!
答案 0 :(得分:0)
我通过在set(BOOST_ROOT C:/local/boost_1_71_0)
大声笑之前添加句子find_package(Boost REQUIRED)
解决了这个问题...
但是我仍然想知道为什么我需要添加它。
答案 1 :(得分:0)
您还可以在创建cmake项目(或CLion和其他IDE中的CMake选项)的过程中设置变量 BOOST_ROOT 。例如:
mkdir buildtest; cd buildtest
cmake -DBOOST_ROOT=/you_path_to_boost/boost ..
cmake --build . -- -j 4
答案 2 :(得分:0)
我在Linux / Manjaro上也有类似的问题。确保已安装Boost,更具体地说是boost开发标头。我安装了boost运行时库,但没有标头。我安装了这些sudo pacman -S boost
,它为我解决了这个问题。
答案 3 :(得分:0)
我解决了这个问题之后,由于这里有了ToughMind,我遇到了以下问题:_Boost_COMPONENT_DEPENDENCIES和_Boost_MISSING_DEPENDENCIES。帮助我的是更新到最新的cmake版本,我从这里得到了答案:CMake finds Boost but the imported targets not available for Boost version