"Qt5-Opencv3.4.9" installation of ubuntu virtual machine under VMware

As long as the installation doesn't stop, the road will continue to extend our efforts, and all of them will be huge

It took a few days to download and install these gadgets. It's a long breath. Write about all kinds of things you encounter when you install the machine. If they are of any help, it will be great.

Reiterate:
This is what I wrote after summing up all kinds of errors during installation and taking measures to avoid pit. If there is a wrong report, it's something I haven't met. Please show your skills.

1, Installation of Qt5

Website: https://download.qt.io/official'releases/qt/
Download the corresponding version according to your own needs. What I choose here is
qt-opensource-linux-x64-5.12.3.run

After downloading, execute the following code at the terminal

sudo apt-get update
cd DownLoads  #"DownLoads" is the folder where qt has been downloaded
chmod +x ./qt-opensource-linux-x64-5.9.1.run 
sudo ./qt-opensource-linux-x64-5.9.1.run 

Double click the icon after the implementation, and click on it under the graphical interface to finish the work. There is a place where you need to select all the nonsense during the installation

After installation, you need to modify the configuration. Enter the following code at the terminal:
(it doesn't have to be vim gedit, just a text editor.)

sudo vim /usr/lib/x86_64-linux-gnu/qt-default/qtchooser/default.conf

Write the bin directory of Qt5 and the directory of Qt5 to the opened documents, for example:

/home/XXX/NUEDC/qt5/5.12.3/gcc_64/bin
/home/XXX/NUEDC/qt5  

In order to avoid misunderstanding, XXX is the user's name

Save to exit the text editor, return to the terminal, and enter the following command:

sudo apt-get install libgl1-mesa-dev

Qt5 installation completed

2, Install and compile opencv3.2.0 (including opencv? Contrib)

1. Install the dependency Library of opencv?

Since I think the dependencies listed here are redundant, I don't know what's useful. I found some commands from many blogs, and finally I can start the next step
Enter the following command at the terminal:

sudo apt-get install libgl1-mesa-dev
sudo apt-get -y install build-essential cmake pkg-config
sudo apt-get -y install libjpeg62-dev
sudo apt-get -y install libtiff4-dev libjasper-dev
sudo apt-get -y install libtiff4-dev
sudo apt-get -y install libtiff5-dev
sudo apt-get -y install libtiff5-dev libjasper-dev
sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev
sudo apt-get install git libgtk2.0-dev
sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
sudo apt-get -y install libopencv-dev build-essential cmake git libgtk2.0-dev pkg-config python-dev python-numpy libdc1394-22 libdc1394-22-dev libjpeg-dev libpng12-dev libjasper-dev libavcodec-dev libavformat-dev libswscale-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libv4l-dev libtbb-dev libqt4-dev libfaac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev x264 v4l-utils unzip
sudo apt-get -y install libopencv-dev build-essential cmake git libgtk2.0-dev pkg-config python-dev python-numpy libdc1394-22 libdc1394-22-dev libjpeg-dev libpng12-dev libjasper-dev libavcodec-dev libavformat-dev libswscale-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libv4l-dev libtbb-dev libqt4-dev libfaac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev x264 v4l-utils unzip  --fix-missing
sudo apt install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
sudo apt install libavresample

Then install CMake to execute the following commands at the terminal:

sudo apt-get install cmake

2. Download Opencv and Opencv contrib

It has to be said that GFW is too blocking in this respect. It's basically impossible to download directly in areas where the network is not available. Let's show our own skills here.

The version numbers of the two files must be the same. (I chose 3.4.9)

After downloading, there are two folders. Put the contrib one in the other (in case of a relative relationship like / opencv3.4.9/opencv_contrib-3.4.9)

3. Compilation (error reporting play)

Execute the following command at the terminal:

sudo apt install cmake-qt-gui
sudo apt-get install ccache

Open the terminal in the opencv main folder (right click + e, cd here), and execute the following command:

mkdir release  #My name here is release. Some blogs use build. It should be OK
cd release
cmake-gui

Operate on the pop-up graphic panel:

1)

"Where is the source code"
Fill in the path of the opencv home folder, and fill in the opencv location, such as "home/XXX/opencv3.4.9"

2)

"Where to build the binaries"
Fill in the path of the contrib folder, such as "home/XXX/opencv3.4.9/opencv_contrib-3.4.9"

3)

Search for free and check in the pop-up

4)

Search contrib. There may not be any columns or columns
If not, click Add Entry next to the search bar
Change Type to Path
Name fill in "opencv? Extra? Modules? Path"
Value fill in the path of the "modules" folder in the contrib folder, for example, "home/XXX/opencv3.4.9/opencv_contrib-3.4.9/modules"

5)

Search qt
Tick the with QT
Change the value after Qt5? Dir to the path of the Qt5 folder under cmake folder, for example, "home / xxx / Qt5 / 5.12.3 / GCC? 64 / lib / cmake / Qt5"

6)

Click Configure in the lower left corner, and then Generate

If everything goes well, there should be only black characters in the small box below, no red characters. But here we may encounter the problem that the file at the beginning of ippicv fails to download.
After trying all kinds of methods, one method finally works. Here is the way I finally use it csdn blog

The steps from the first step of compiling to here are written after I have summed up all kinds of errors during the installation and taken measures to avoid the pit. If at this stage, configure still has a red ink error (for example, zdy just asked), it's something I haven't met. Please show your own powers.

Come on Ollie!!!

7)

Enter the following command in the terminal from cd to release folder:

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D WITH_QT=On -D WITH_OPENGL=ON OPENCV_EXTRA_MODULES_PATH=/home/XXX/opencv3.4.9/opencv_contrib-3.4.9/modules/ ..

Cmake? Install? Prefix is the installation directory of the library file. It is recommended to use this directory. With? QT = on must be selected, and opencv? Extra? Modules? Path = must be followed by the absolute path of your contrib (relative path is unknown or not). The last two must be added.

8)

Enter the following command in the terminal from cd to release folder:

sudo make -j8 

The last number represents the actual number of threads in the machine. For example, eight thread CPU writes j8. If the x here is too small, compilation will be too slow, and if there are too many threads, it will crash. Please be careful.

I may encounter strange errors here. I have encountered the following error reports:
c++: internal compiler error: Killed (program cc1plus)

It is found that there is insufficient memory after query. Some say it's solved with virtual memory. It's too big. But since this is a virtual machine, I use shutdown to allocate memory in vmware

3, Finishing, testing

Refer to steps 9 to 12 of this blog csdn blog
Enter the following command at the terminal before executing step 12:

export LD_LIBRARY_PATH=/home/XXX/qt5/5.12.3/gcc_64/lib/

Four.

Hooray!

Published 11 original articles, won praise 4, visited 3290
Private letter follow

Tags: sudo Qt5 Qt cmake

Posted on Fri, 07 Feb 2020 06:12:38 -0800 by toniknik1982