對cmake的使用不是很熟悉,遇到這個問題爲自己簡單記錄一下。
錯誤如下:
CMake Error at CMakeLists.txt:39 (find_package):
By not providing "FindOpenCV.cmake" in CMAKE_MODULE_PATH this project hasasked 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時,不是使用的默認的路徑,導致cmake找不到opencv
解決方法:
首先 export OpenCV_DIR=/usr/local/opencv-3.1.0
然後在build目錄下執行 cmake .. 即可