Cmake错误:找不到Boost(缺少:Boost\u INCLUDE\u DIR)

Cmake错误:找不到Boost(缺少:Boost\u INCLUDE\u DIR),boost,cmake,Boost,Cmake,我不熟悉Cmake和Boost。我现在正在使用cmake开发一个程序,需要帮助 系统:windows 7 Cmake版本:3.16.0-rc1 Boost版本:Boost_1_71_0。boost是通过.exe文件安装的。 Gcc版本:4.8.1(第5版,由MinGW-W64项目构建) Visual studio:vs 2015 在builddir中运行cmake..时,不会发生错误。输出为: The C compiler identification is MSVC 19.0.24215.1

我不熟悉Cmake和Boost。我现在正在使用cmake开发一个程序,需要帮助

系统:windows 7
Cmake版本:3.16.0-rc1
Boost版本:Boost_1_71_0。boost是通过.exe文件安装的。
Gcc版本:4.8.1(第5版,由MinGW-W64项目构建)
Visual studio:vs 2015

build
dir中运行
cmake..
时,不会发生错误。输出为:

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
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".
但是我想使用minGW进行编译,所以当我rum
cmake-G“minGW makefile”
时,出现了一个错误:“找不到Boost(缺少:Boost\u INCLUDE\u DIR)”。输出为:

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
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”
时如何解决错误?谢谢大家

我通过在
查找包(需要BOOST)之前添加句子
set(BOOST\u ROOT C:/local/BOOST\u 1\u 71\u 0)
解决了这个问题。。。
但是我仍然想知道为什么我需要添加这个。

您还可以在创建cmake项目(或CLion和其他IDE中的cmake选项)的过程中设置变量BOOST\u ROOT。例如:

mkdir buildtest; cd buildtest
cmake -DBOOST_ROOT=/you_path_to_boost/boost ..
cmake --build . -- -j 4

我在Linux/Manjaro上遇到了类似的问题。确保已安装boost,更具体地说是boost开发标题。我安装了boost运行库,但没有安装头。我安装了那些
sudopacman-sboost
,它为我解决了这个问题

在我解决了这个问题之后,多亏了这里的ToughMind,我遇到了以下问题:\u Boost\u COMPONENT\u DEPENDENCIES和\u Boost\u MISSING\u DEPENDENCIES。帮助我的是更新到最新的cmake verison,我从这里得到了答案: