參考網站 html
http://www.cnblogs.com/fesh/p/4110535.html python
http://www.it1352.com/324364.html (python 問題解決) c++
http://stackoverflow.com/questions/18729495/installing-opencv-with-python-module-on-centos-goes-wrong/18733071#18733071 (python 問題解決) vim
http://www.jb51.net/os/RedHat/280309.html (依賴安裝,cmake參數) centos
redhat安裝opencv
1、直接cmake python2.7
問題: 網站
-
make[1]: *** [modules/python/CMakeFiles/opencv_python.dir/all] Error 2
-
make[2]: *** [lib/cv2.so] Error 1
-
libpython2.7.a(abstract.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a shared object; recompile with -fPIC
解決: ui
You need to reinstall python with shared and static way. spa
Firstly, download Python source file again. .net
and then..
從新安裝python
-
tar xvf Python-2.7.12.tgz
-
cd Python-2.7.12
-
./configure –shared-static
-
make
-
sudo Make install
2、安裝依賴包
-
yum install cmake gcc gcc-c++ gtk+-devel gimp-develgimp-devel-tools gimp-help-browser zlib-devel libtiff-devel libjpeg-devellibpng-devel gstreamer-devel libavc1394-devel libraw1394-devel libdc1394-develjasper-devel jasper-utils swig python libtool nasm
3、生成make文件並安裝
-
cd opencv2.3.1
CMake配置
-
cmake -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=/usr/local -DBUILD_NEW_PYTHON_SUPPORT=NO 。
//這裏可能提示line44錯誤。 進去Cmakelist.txt,把第44行註釋掉
// 注意NO後面爲空格+. 必不可少。
Build files have been written to :/****表示cmake成功
編譯
-
make //編譯,須要較長時間
[100%] Built target opencv_visualisation
編譯成功
安裝
-
sudo make install
配置
-
vim /etc/ld.so.conf.d/opencv.conf //建立pkg-config配置文件
/usr/lib //添加配置文件/usr/lib/pkgconfig/opencv.pc位置
或者是/usr/local/lib //位置必定要正確