linux Installation Configuration: opencv3.4.6 + opencv3.4.6

[official website, look at this if you have any questions]

This brother has helped me a lot, but I have some problems when I carry out some detailed steps, so there will be many differences.


1. Download the specified version of opencv for linux

Generally speaking, github is slow to hang up a ladder and download quickly.

2. Put it into the server or computer target directory to decompress

  • To the corresponding directory

  • Entry directory
cd opencv-3.4.6
  • Create a folder called build
mkdir build

3. cmake

  • Go into the folder
cd build
  • Configure cmake

The main function is to configure, generate output and files to the specified location.
(- D should not be followed by a space, otherwise there will be an error that the directory cannot be found.)

4. make instruction

sudo make

sudo make install

  • This instruction can improve the execution speed of make on multi-core host and allow 7 parallel tasks at the same time
make -j7

(here is the original words on the official website)

5. Generate files

  • Enter doc folder
cd doc

make -j7 doxygen

6. Configure environment variables

  • Switch to superuser
sudo su
  • Modify the configuration with the privileges of super user
vi /etc/

Add at the end of the file: / usr/local/opencv346/lib (possibly an empty file)

  • Open vim again
vi /etc/bash.bashrc
  • Add at the end of the file:

Restart the terminal after configuration to make the configuration effective.
Or perform:

source /etc/bash.bashrc
sudo updatedb
  • You can check whether the installation is successful. If it is successful, the following is displayed
ldconfig -v | grep opencv


cd build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local/opencv346 -DPYTHON_DEFAULT_EXECUTABLE=$(which python3) -DOPENCV_EXTRA_MODULES_PATH=../opencv_contrib-3.4.6/modules -DWITH_TBB=ON -DWITH_EIGEN=ON ..

(because the location of python3 in my server has been changed, so I write as follows)

cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local/opencv346 -DPYTHON_DEFAULT_EXECUTABLE=$(which /usr/bin/python3) -DOPENCV_EXTRA_MODULES_PATH=../opencv_contrib-3.4.6/modules -DWITH_TBB=ON -DWITH_EIGEN=ON ..
sudo make

There are two types of problems:

1⃣️When installing OpenCV, you will be prompted for a solution to the problem of missing the bootdesc? BGM. I file (with resources)

The main problem of the solution is clearly written, and there is no repetition here.

Replication method

2⃣️Solutions to opencv2/xfeatures2d/cuda.hpp: No such file or directory class problems

Take "opencv2/xfeatures2d/nonfree.hpp" as an example, the absolute path is:


Continue to execute our sudo make.

  • At last!


sudo make install

Installation complete!

Start detection using opencv

cd /home/liu/Dear/opencv-3.4.6/samples/cpp/example_cmake
cmake .

Because I didn't call the camera, it shows build but I didn't catch it. But the installation is ok!

Published 19 original articles, won praise 16, visited 6199
Private letter follow

Tags: OpenCV sudo cmake github

Posted on Wed, 05 Feb 2020 07:50:54 -0500 by evmace