解決“CMake Error at CMakeLists.txt:9 (find_package)”的方法

CMake Error at CMakeLists.txt:9 (find_package):
By not providing "FindOpenCV.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "OpenCV", but
CMake did not find one.

Could not find a package configuration file provided by "OpenCV" with any
of the following names:

OpenCVConfig.cmake
opencv-config.cmake

Add the installation prefix of "OpenCV" to CMAKE_PREFIX_PATH or set
"OpenCV_DIR" to a directory containing one of the above files. If "OpenCV"
provides a separate development package or SDK, be sure it has been
installed.


"此電腦"->"屬性"->"環境變量"->"系統變量"->新建,添加“變量名”:OpenCV_DIR;變量值:C:\Program Files\OpenCV.3.4.10\opencv\build 

在即將使用CMake編譯的CMakeLists文件中找到下圖所示設置的路徑:

將CMakeLists文本中設置OpenCV_DIR改爲:#set(OpenCV_DIR  "/path/to/opencv/build"),然後編譯,問題得解決!

 參考博文:

1、CMake找不到opencv庫解決辦法

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章