2014年3月27日 星期四

【OpenCV】Build OpenCV Static Library on Ubuntu 在Ubuntu上編譯OpenCV靜態庫

最近在想玩看看編譯OpenCV靜態庫,但一直遇到一些問題,包含以下幾項:
1.
undefined reference to `std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >::~basic_string()'
undefined reference to `typeinfo for int'
2.
undefined reference to symbol 'v4l2_close'
建議用乾淨的環境來編譯,因為本身用同樣的方式編譯卻遇到不同的問題,最後是因為重新安裝Ubuntu 12.10後在進行以下的方式編譯,最後才成功的。(WITH_LIBV4L=OFF)
3.
undefined reference to symbol 'v4l2_memory_mmap'

也參考過很多解決方式,但都沒改善,可能是我自己誤解別人意思,包含WITH_CUDA=OFF或安裝新的v4l library...

==========================編譯OpenCV 2.4.8 靜態庫==========================
======================== Build OpenCV 2.4.8 static library ======================

~安裝開發環境GCC、Cmake、pkgconfig
sudo apt-get -y install build-essential cmake pkg-config

~安裝 ImageI/O libraries
sudo apt-get -y install libjpeg62-dev libtiff4-dev libjasper-dev

~安裝 Viode I/O libraries
sudo apt-get -y install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev
sudo apt-get -y install libdc1394-22-dev libxine-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev

~安裝 GTK+2.x and QT libraries
sudo apt-get -y install  libgtk2.0-dev libqt4-dev

~(選)安裝 support for Firewire video cameras
sudo apt-get -y install libdc1394-22-dev

~(選)安裝 video streaming libraries
sudo apt-get -y install libxine-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev

~(選)安裝 the Python development environment and the Python Numerical libraries
sudo apt-get -y install python-dev python-numpy

~(選)安裝TBB library(Intel® Threading Building Blocks)(平行化處理的函式庫)
sudo apt-get -y install libtbb-dev

~下載openCV2.4.8版本
wget https://github.com/Itseez/opencv/archive/2.4.8.tar.gz

~解壓縮
tar xvf 2.4.8.tar.gz

~移動至opencv的資料夾
cd opencv-2.4.8

~建立一個資料夾,名稱為build
mkdir build

~移動至build資料夾
cd build

~Cmake指令,依照自行設定增加或減少指令
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D WITH_LIBV4L=OFF -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_GTK=OFF -D WITH_OPENGL=ON -D BUILD_SHARED_LIBS=OFF -D OPENCV_BUILD_3RDPARTY_LIBS=ON -D WITH_JPEG=ON -D WITH_JASPER=ON -D WITH_TIFF=ON -D WITH_PNG=ON ..
  • CMAKE_BUILD_TYPE=RELEASE : cmake will bulid a release project
  • CMAKE_INSTALL_PREFIX=/usr/local : directory to be used as a installation destination
  • BUILD_PYTHON_SUPPORT : enable python support
~開始編譯
make

~安裝
sudo make install

0 意見:

張貼留言