Ubuntu18源碼編譯OpenCV4.3

Ubuntu18源碼編譯OpenCV4.3

參考資料

過程

  1. 首先更新包
# Install the newest versions of all packages currently installed
sudo apt-get -y upgrade
# Handles changing dependencies with new versions of packages
sudo apt-get -y dist-upgrade
# Remove packages that are now no longer needed
sudo apt-get -y autoremove
  1. 安裝OpenCV所需依賴
# Build tools:
sudo apt-get install -y build-essential cmake

# GUI (if you want to use GTK instead of Qt, replace 'qt5-default' with 'libgtkglext1-dev' and remove '-DWITH_QT=ON' option in CMake):
sudo apt-get install -y qt5-default libvtk6-dev

# Media I/O:
sudo apt-get install -y zlib1g-dev libjpeg-dev libwebp-dev libpng-dev libtiff5-dev libjasper-dev libopenexr-dev libgdal-dev

# Video I/O:
sudo apt-get install -y libdc1394-22-dev libavcodec-dev libavformat-dev libswscale-dev libtheora-dev libvorbis-dev libxvidcore-dev libx264-dev yasm libopencore-amrnb-dev libopencore-amrwb-dev libv4l-dev libxine2-dev

# Parallelism and linear algebra libraries:
sudo apt-get install -y libtbb-dev libeigen3-dev

# Python:
sudo apt-get install -y python-dev python-tk python-numpy python3-dev python3-tk python3-numpy

# Java:
sudo apt-get install -y ant default-jdk

# Documentation:
sudo apt-get install -y doxygen
  1. 安裝過程
mkdir build & cd build
sudo cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D WITH_EIGEN=ON ..
sudo make	# compile
sudo make install	# install
sudo ldconfig	# load config

錯誤及解決

make過程當中報錯,查資料後發現是虛擬機的虛擬內存太小,關機後從新調整便可。web

c++: internal compiler error: Killed (program cc1plus)
  1. 檢查是否成功安裝OpenCV庫
    /samples/cpp/example_cmake下有個工程,編譯後,若是成功運行而且顯示"Hello OpenCV",則安裝成功
    且在/usr/local/includes/下有opencv4的庫

最後還有個多版本的問題,查資料後,看到網上不少多版本並存的解決方案,先這樣,有空再試。ubuntu

相關文章
相關標籤/搜索