我正在尝试构建依赖于OpenCV的项目.我使用macports安装了Opencv,当我尝试构建项目时,cmake提供了以下输出:
CMake Error at CMakeLists.txt:47 (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.
我搜索了一下这个问题,并添加了以下环境.变量到我的$HOME / .profile文件
export DYLD_LIBRARY_PATH=/opt/local/lib:$DYLD_LIBRARY_PATH export CMAKE_PREFIX_PATH=/opt/local
没有成功.我检查了所有opencv文件都在/ opt / local / lib和/ opt / local / include / opencv目录中.以下路径中还有OpenCVConfig.cmake:
/opt/local/lib/cmake/OpenCVConfig.cmake
如何让cmake知道opencv的安装路径?以前我使用cmake自己构建OpenCV并安装到/usr/local然后它没有任何其他修复工作正常.但是我对ffmpeg有一些问题,现在我转而使用macports.
另一个适用于我的选项是在cmake opencv目录中设置env值OpenCV_DIR:
原文链接:https://www.f2er.com/javaschema/281307.htmlexport OpenCV_DIR=/opt/local/lib/cmake/