$ sudo apt install build-essential pkg-config cmake ninja-build
$ sudo apt install libjpeg-dev libpng-dev libtiff-dev libjasper-dev libwebp-dev libopenexr-dev
$ sudo apt install libgtk2.0-dev libgtk-3-dev
$ sudo apt install libavcodec-dev libavformat-dev libavresample-dev libswscale-dev libdc1394-22-dev
$ sudo apt install libdc1394-22-dev libv4l-dev libxvidcore-dev libx264-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
$ sudo apt install libtbb-dev libatlas-base-dev liblapacke-dev gfortran libeigen3-dev
$ sudo apt install libprotobuf-dev protobuf-compiler
$ sudo apt install libgoogle-glog-dev libgflags-dev
$ sudo apt install libhdf5-dev
$ sudo apt install python3 python3-wheel python3-pip python3-venv python3-setuptools python3-dev python3-numpy
- Install MSYS2 (https://www.msys2.org)
- Open
Start Menu > MSYS2 64bit > MSYS2 MSYS
and run the following commands:
$ pacman -Syu
$ ########## Close terminal window. ##########
$ pacman -Su
$ pacman -S base-devel
$ pacman -S mingw-w64-i686-toolchain
$ pacman -S mingw-w64-x86_64-toolchain
$ pacman -S mingw-w64-i686-cmake
$ pacman -S mingw-w64-x86_64-cmake
- To compile 32-bit version:
Start Menu > MSYS2 64bit > MSYS2 MinGW 32-bit
- To compile 64-bit version:
Start Menu > MSYS2 64bit > MSYS2 MinGW 64-bit
- Dependencies:
$ cd opencv-x.y.z/build
$ cmake \
-G "MSYS Makefiles" \ # For Windows
-D OPENCV_EXTRA_MODULES_PATH=./../../opencv_contrib-x.y.z/modules \
-D CMAKE_BUILD_TYPE=Release \
-D BUILD_SHARED_LIBS=ON \
-D BUILD_JPEG=ON \
-D BUILD_PNG=ON \
-D BUILD_TIFF=ON \
-D BUILD_ZLIB=ON \
-D ENABLE_NEON=ON \ # For ARM (eg. Raspberry Pi)
-D ENABLE_VFPV3=ON \ # For ARM (eg. Raspberry Pi)
-D CMAKE_SKIP_RPATH=ON \
-D CMAKE_SHARED_LINKER_FLAGS=-Wl,-rpath,\$ORIGIN \
-D OPENCV_GENERATE_PKGCONFIG=ON \
-D CMAKE_INSTALL_PREFIX=~/opencv \
..
$ make
$ make install