本文参考http://blog.csdn.net/tankaro/article/details/74451812博文。
在此基础上移植了opencv3.4.0
1.环境准备,安装一些依赖库
sudo apt-get install manpages-posix-dev
sudo apt-get install glibc-doc
sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libtiff5-dev libjasper-dev libdc1394-22-dev
sudo apt-get install cmake git libgtk2.0-dev pkg-config libswscale-dev cmake-qt-gui
2.下载opencv源码,以下以3.4.0为例:
Git:https://github.com/opencv/opencv/releases/tag/3.4.0
3.cmake配置:
在opencv源码目录下执行命令cmake-gui
在opencv目录下创建output目录,然后按下面图示填写
然后点击configure按钮
退出cmake-gui
进入output目录后执行make
出现如下错误:
/home/huangea/opencv-3.4.0/3rdparty/protobuf/src/google/protobuf/stubs/common.cc:51:2: error: #error “No suitable threading library available.” #error “No suitable threading library available.” ^ make[2]: *** [3rdparty/protobuf/CMakeFiles/libprotobuf.dir/src/google/protobuf/stubs/common.cc.obj] Error 1 make[1]: *** [3rdparty/protobuf/CMakeFiles/libprotobuf.dir/all] Error 2 make: *** [all] Error 2 #### make failed to build some targets (1 seconds) ####
查看opencv-3.4.0/3rdparty/protobuf/src/google/protobuf/stubs/common.cc文件,发现是找不到HAVE_PTHREAD宏定义导致找不到pthread库,本文解决办法就是在该文件加上该句宏定义(临时解决,有其他更好的方法欢迎告知探讨)#define HAVE_PTHREAD
最后解决了编译问题,编译好的库在output/lib下。
找了好久才找到这里,来了就不想走!
非常厉害,希望您以后发展越来越好!