您能夠省去以下步驟,直接下載我編譯好的:linux
http://download.csdn.net/detail/u011258240/9710331
ubuntu
1、編譯opencv2.4 不帶contribide
1. 下載opencv源碼ui
2. 將opencv 源碼放在linux 的一個文件夾下(記得不要放在共享文件夾下,否則會出現軟連接的錯誤)spa
3. opencv目錄下新建文件夾 release ( 注:若是是3.3版本,還要刪除這兩個文件,很關鍵 rm -rf CMakeCache.txt CMakeFiles, 若是cmake版本低還要更新cmake版本 :https://launchpad.net/ubuntu/+source/cmake/3.9.1-1).net
4.新建opencv的安裝文件夾,例如mkdir /opencv1
3d
5. cd release源碼
cmake ../ \it
-DCMAKE_BUILD_TYPE=RELEASE \編譯
-DCMAKE_INSTALL_PREFIX=/opencv3.3 \
-DWITH_TBB=1 \
-DWITH_PNG=1 \
-DWITH_TIFF=1 \
-DWITH_JPEG=1 \
-DWITH_JASPER=1 \
-DBUILD_SHARED_LIBS=0 \
-D INSTALL_C_EXAMPLE=OFF \ -D INSTALL_PYTHON_EXAMPLE=OFF \ -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-3.2.0/modules \ -D BUILD_EXAMPLES=ON ..
cmake ../ -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=/opencv3.3 -DWITH_TBB=1 -DWITH_PNG=1 -DWITH_TIFF=1 -DWITH_JPEG=1 -DWITH_JASPER=1 -DBUILD_SHARED_LIBS=0
6. make
7, make install
而後查看文件夾opencv1,顯示生成了靜態庫
root@lyj:/opencv1# ls lib
libopencv_calib3d.a libopencv_flann.a libopencv_legacy.a libopencv_ocl.a libopencv_ts.a
libopencv_contrib.a libopencv_gpu.a libopencv_ml.a libopencv_photo.a libopencv_video.a
libopencv_core.a libopencv_highgui.a libopencv_nonfree.a libopencv_stitching.a libopencv_videostab.a
libopencv_features2d.a libopencv_imgproc.a libopencv_objdetect.a libopencv_superres.a pkgconfig
8. 特別注意:opencv 編譯的靜態庫並不包含libpng.a libjpeg 等庫,這些庫也要本身編譯。
9. 靜態庫的使用:記得必定要包含以下庫,否則使用可能會出問題
-llibjasper
-llibjpeg \
-llibpng \
-lIlmImf \
-llibtiff \
-ldl \
-lz \
2、 編譯opencv3.3 + contrib 靜態庫
cd opencv-3.3.0
mkdir build
cd build
cmake ../ \
-DCMAKE_BUILD_TYPE=RELEASE \
-DCMAKE_INSTALL_PREFIX=/opencv3.3 \
-DBUILD_SHARED_LIBS=0 \
-DINSTALL_C_EXAMPLE=OFF \
-DINSTALL_PYTHON_EXAMPLE=OFF \
-DENABLE_SSE=ON \
-DOPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-3.3.0/modules \-DBUILD_EXAMPLES=OFF