Linux下編譯OpenCVpython
# 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
# 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
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)
/samples/cpp/example_cmake
下有個工程,編譯後,若是成功運行而且顯示"Hello OpenCV",則安裝成功/usr/local/includes/
下有opencv4的庫最後還有個多版本的問題,查資料後,看到網上不少多版本並存的解決方案,先這樣,有空再試。ubuntu