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.
- forth step: without build python and java model
In CMakeLists.txt file, delete the python model and java model.
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.
- finally make -j2 ; make install