参考博客:http://blog.csdn.net/hansry/article/details/75309906
报错:CMake Error at CMakeLists.txt:7 (find_package):
Could not find a configuration file for package "OpenCV" that is compatible
with requested version "3.1".
The following configuration files were considered but not accepted:
/usr/OpenCV/OpenCVConfig.cmake, version: 2.4.8
查询现在系统中的版本是2.4.8
pkg-config --modversion opencv
以前也安装过3.1.0,所以安装包都有。
进入解压缩之后的文件夹,进入build文件夹,先清空build文件夹,然后cmake
cmake -D CMAKE_BUILD_TYPE=RELEASE -D WITH_TBB=ON -D WITH_V4L=ON -D CMAKE_INSTALL_PREFIX=/usr/local/opencv310 ..
可以发现,上面cmake的时候指定了安装路径为
/usr/local/opencv310
然后依然是
make -j2
sudo make install
安装结束就可以在/usr/local/目录下看到opencv310这个文件夹了
使用:
CMakeLists.txt文件里面这样设置:
# OpenCV 3.1.0