Linux Ubuntu下安装OpenCv2.4.10

参考 http://blog.sina.com.cn/s/blog_53b0956801010lfu.html

捣鼓了一个晚上了,OpenCv还没装好,本来以为看个类似的比如Ubuntu安装OpenCv2.2或者其他的就能安装好,结果发现...我太天真了。

网上使用Ubuntu12.04来装OpenCv还是挺多的,各种版本组合教程,都没能把我的Ubuntu12.04+OpenCv2.4.10 成功合体。

 

灰心之极到OpenCv官网想下载个OpenCv2.4.0发现没有....

只好假装屡败屡战了。

  

  

  回到刚刚的现实...

 

以下是步骤:

  

更新软件列表,升级
sudo apt-get update
sudo apt-get upgrade

安装依赖包
sudo
apt-get install build-essential libgtk2.0-dev libjpeg-dev libtiff4-dev
libjasper-dev libopenexr-dev cmake python-dev python-numpy python-tk libtbb-dev
libeigen2-dev yasm libfaac-dev libopencore-amrnb-dev libopencore-amrwb-dev
libtheora-dev libvorbis-dev libxvidcore-dev libx264-dev libqt4-dev
libqt4-opengl-dev sphinx-common texlive-latex-extra libv4l-dev libdc1394-22-dev
libavcodec-dev libavformat-dev libswscale-dev

下载opencv安装包

http://sourceforge.net/projects/opencvlibrary

最新版本已经到3.0了!!!  可是关我什么事....

 

解压
tar -xvf OpenCV-2.4.2.tar.bz2
cd OpenCV-2.4.2

创建编译目录
mkdir
build
cd build

cmake生成make文件
cmake -D WITH_TBB=ON -D
BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D
INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON
..
检查输出:不能有error;FFMPEG : YES;Python, TBB, OpenGL, V4L, OpenGL and Qt are
detected。如果有问题要重新安装对应的包再cmake

编译(需要很长时间)
make

 

到了这一步就卡住了,输出错误

 make
[  0%] Generating opencv_core_pch_dephelp.cxx
Scanning dependencies of target opencv_core_pch_dephelp
[  0%] Building CXX object modules/core/CMakeFiles/opencv_core_pch_dephelp.dir/opencv_core_pch_dephelp.cxx.o
Linking CXX static library ../../lib/libopencv_core_pch_dephelp.a
[  0%] Built target opencv_core_pch_dephelp
Scanning dependencies of target pch_Generate_opencv_core
[  0%] Generating precomp.hpp
[  0%] Generating precomp.hpp.gch/opencv_core_Release.gch
[  0%] Built target pch_Generate_opencv_core
Scanning dependencies of target opencv_core
[  0%] Building CXX object modules/core/CMakeFiles/opencv_core.dir/src/system.cpp.o
/tmp/opencv-2.4.10/modules/core/src/system.cpp: In function ‘(static initializers for /tmp/opencv-2.4.10/modules/core/src/system.cpp)’:
/tmp/opencv-2.4.10/modules/core/src/system.cpp:280:10: error: inconsistent operand constraints in an ‘asm’
make[2]: *** [modules/core/CMakeFiles/opencv_core.dir/src/system.cpp.o] Error 1
make[1]: *** [modules/core/CMakeFiles/opencv_core.dir/all] Error 2
make: *** [all] Error 2

 

  在网上查找了一下错误信息,没什么收获...

  突然想研读一下这是个什么错误...看了半天觉得另寻出路吧。

 

继续寻找

  发现一篇不错的博文http://www.linuxidc.com/Linux/2014-04/100112.htm

  然后继续发现我少装了一个工具,于是

  sudo apt-get install cmake-curses-gui 

 

  接下来是继续弄了

                                                                                                      

 

开始安装 将从官网下载的源码 opencv2.4.8.zip 复制到 /home/own 下,cd到该目录,执行

unzip opencv2.4.8.zip 

cd opencv2.4.8 

mkdir release 

cd release  ccmake ../

 

进入ccmake后,按 c 就会弹出如下界面

把 BUILD_JPEG 和 BUILD_PNG 这两项改成了 ON ,其余全部都默认,键盘按c,然后按g,然后就回到命令行界面,

make 

 

比上次多出了很多.o文件,然后很顺利的一直进行...

 

但是,

突然又出现

/tmp/opencv-2.4.10/modules/core/src/system.cpp: In function ‘(static initializers for /tmp/opencv-2.4.10/modules/core/src/system.cpp)’:
/tmp/opencv-2.4.10/modules/core/src/system.cpp:280:10: error: inconsistent operand constraints in an ‘asm’
make[2]: *** [modules/core/CMakeFiles/opencv_core.dir/src/system.cpp.o] Error 1
make[1]: *** [modules/core/CMakeFiles/opencv_core.dir/all] Error 2
make: *** [all] Error 2

 

  郁闷之极...

  未完待续。。。

 

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。