centos6.4安装opencv2.4.10

1.下载opencv2.4.10源码
2.安装cmake cmake-gui

3.解压opencv2.4.10,并在相应目录下创建一个build目录用于编译使用

4.执行cmake-gui进行设置
设置release TTB example(3项) QT OPENGL
5.执行make

6.发生错误1
/opencv-2.4.10/modules/core/src/system.cpp:280:10: error: inconsistent operand constraints in an ‘asm’
make[3]: * [modules/core/CMakeFiles/opencv_core.dir/src/system.cpp.o] Error 1
此时打开opencv-2.4.10/modules/core/src/system.cpp文件,定位到270行-280行(即:asm volation(…)); 利用如下内容替代( 解决方案出处):

// We need to preserve ebx since we are compiling PIC code. 
// This means we cannot use "=b" for the 2nd output register. 
asm volatile 
( 
"pushl %%ebx\n\t" 
"movl $7,%%eax\n\t" 
"movl $0,%%ecx\n\t" 
"cpuid\n\t" 
"movl %%ebx,%1\n\t" 
"popl %%ebx\n\t" 
: "=a"(cpuid_data[0]), "=r"(cpuid_data[1]), "=c"(cpuid_data[2]), "=d"(cpuid_data[3]) 
: 
: "cc" 
); 

7.发生错误2
opencv-2.4.8/modules/highgui/src/grfmt_png.cpp:388: error: `Z_FIXED’ was not declared in this scope

原因是包含了系统头文件路径/usr/include/zlib.h , 对应的zlib版本太老。解决方法:

打开opencv-2.4.8/modules/highgui/src/grfmt_png.cpp ,增加:
增加宏定义:#define Z_FIXED 4
8.make成功
9.make install
10.测试:
复制目录samples/c下的所有文件,执行./build_all.sh进行编译
执行./find_obj


参考文章:http://www.yyearth.com/article/13-12/opencv.html
http://blog.sina.com.cn/s/blog_675e6b570101gpsj.html

你可能感兴趣的:(centos6.4安装opencv2.4.10)