cdopencv-2.1.0mkdir release && cd releasecmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -DWITH_FFMPEG=OFF..make sudo make install 安装目录为/usr/localopencv的库文件则在 /usr/local/lib目录下
3:常见编译错误解决办法
1:error ‘ptrdiff_t’ does not name a type opencv解决方法:在/include/opencv/cxcore.hpp文件中添加如下一行using std::vector;using std::string;+using std::ptrdiff_t;//这是加的一行 在56行2: error: ‘unlink’ was not declared in this scope解决方法:在src/highgui/loadsave.cpp中加入如下一行#include<unistd.h> 3:error: ‘CODEC_ID_H264’ was not declared in this scope解决方法:方法1:sudo apt-get install libopencv-dev然后以下面的方法重新编译ffmpeg:./configure --enable-shared --disable-staticmakesudo make install方法2:不使用ffmpeg,直接在cmake时禁掉FFMPEG这一项 -DWITH_FFMPEG=OFF4:undefined reference to `cvCreateCameraCapture_V4L(int)"vim opencv-2.1.0/src/highgui/cvcap_v4l.cpp 217 #ifdef HAVE_CAMV4L 218 #include <linux/videodev.h> 219 #endifvim opencv-2.1.0/src/highgui/cvcap.cpp 把164#if defined (HAVE_CAMV4L) || defined (HAVE_CAMV4L2)改为164 #if defined (HAVE_CAMV4L)5:其它的几个错误都是unlike不找不到declare,只面要在相应的源文件中加入unistd.h头文件即可解决 最后终于编译通过:Linking CXX shared library ../../lib/cv.so[100%] Built target cvpy