1. The need to download the file:
On a, source version of opencv. In the official website to download the best, albeit slow but the file will not be a problem. I downloaded the 3.4.0 version, link here: https://opencv.org/releases/page/3/ .
Attention must be source version, because the next step is to compile and install the source code. Downloaded a zip archive, first detour.
2. The need to rely on and build tools:
Open a command line, type the following sentence statement and install any dependencies:
sudo apt-get install build-essential libgtk2.0-dev libavcodec-dev libavformat-dev libjpeg.dev libtiff4.dev libswscale-dev libjasper-dev
File a little more, it can be patient.
Enter the next sentence statement install compilation tools cmake:
sudo apt-get install cmake
May be more demanding compiled the future, you can install cmake install a tape interface After cmake:
sudo apt-get install cmake-gui
3. Compile source installation
Please have a protagonist debut:
Here archive temporarily put on the table, extract directly on the desktop. If you have not been installed, then zip tools need to knock install the following statement:
sudo apt-get install zip
Then decompress:
unzip opencv-3.4.0.zip
Unzip the folder into finished their directory, where I created a new folder in the home directory opencv, then opencv-3.4.0 folder into.
Create a new folder in the opencv-3.4.0, to save the file compiled:
mkdir my_build
My_build into the new folder:
cd my_build
Enter cmake to compile the following sentence be:
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local ..
Run the above three instructions following schematic:
the make up after a good cmake:
sudo make
Install them:
sudo make install
Installed, ready to configure the environment variables.
4. Configuration Environment
Enter the following, open profile
sudo gedit /etc/ld.so.conf.d/opencv.conf
As shown below, there should be nothing.
Written in the file: /usr/local/lib
you can save out.
/usr/local/lib
Note that usr, instead of writing user !!!
Run the following commands to validate the configuration:
sudo ldconfig
Continue to bash configuration file:
sudo gedit /etc/bash.bashrc
In the end of the file add:
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
export PKG_CONFIG_PATH
Save to close.
source about the configuration to take effect immediately:
source /etc/bash.bashrc
And then update the look:
sudo updatedb
Since environment configuration is complete.
5. Routine test run
Came opencv-3.4.0 folder. And then click Open samples, cpp, example_cmake. Here is the official routines can test.
In turn enter the following statement:
cmake .
make
./opencv_example
The code to run successfully, ok.