Debian || Ubuntu编译安装OpenCV(Only C++ without Python!)

Debian源码编译安装OpenCV C++版本

Only compile opencv c++, without python and java.

  • first step: install dependency.

sudo apt-get install build-essential
sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev qtbase5-dev libtiff-dev

  • second step: download opencv source code.

In Linux operate system, you can use this command line: wget https://github.com/opencv/opencv/archive/4.1.0.zip, or use git clone https://github.com/opencv/opencv.git

  • third step

Entire the opencv source code directory and make a directory build, and you can also use another name, it’s no matter. Debian || Ubuntu编译安装OpenCV(Only C++ without Python!)_第1张图片

  • forth step: without build python and java model

In CMakeLists.txt file, delete the python model and java model.
Debian || Ubuntu编译安装OpenCV(Only C++ without Python!)_第2张图片
Debian || Ubuntu编译安装OpenCV(Only C++ without Python!)_第3张图片
Entire the directory that you made just a minute ago, and in this directory, execute the following command:
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=~/${your_directory}
I suggest the CMAKE_INSTALL_PREFIX opencv in a directory that you want to install and don’t use : /usr/local directory, because if you want to uninstall this version of opencv, you can only delete the directory that you installed opencv.
In this blog, I use the following command to install OpenCV in my laptop:

  • cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/home/wangheng/app/opencv4
    Maybe you want to install with CUDA or CUDNN, you can add the string: -D WITH_CUDA=ON and so on.
    Debian || Ubuntu编译安装OpenCV(Only C++ without Python!)_第4张图片
  • finally make -j2 ; make install

你可能感兴趣的:(开发环境,编译opencv,C++)