Background:
Ubuntu 15.04
Qt 5.2.1
OpenCV 3.0.0
All the information comes from the network, I am just the porter of the information.
First, we should install a few necessary things
sudo apt-get install build-essential cmake libgtk2.0-dev pkg-config python-dev python-numpy Libavcodec-dev Libavformat-dev Libswscale-dev
Here, I feel there are some python-related, without installation (I'm using C + + here). I didn't do the verification.
Second, GCC is still to be installed, although the Ubuntu system will be brought, but still mention it:
sudo apt-get install gcc
Go to OPENCV official website to download the Linux version of OpenCV, here I would like to mention, different OpenCV compilation method, roughly the same, but there are still some differences, this should be noted.
Download OK, you can unzip the compressed files, I usually unzip here to the/home/x folder, X is the user name.
Unzip it, get into/home/x/opencv-3.0.0.
Here's an online tutorial that provides a way to compile. Create a folder called release in opencv-3.0.0 (the name doesn't matter)
Here we need to cmake this thing, use it to compile, cmake in the previous command has been installed, we don't have to worry about it.
This requires such a command, CMake compiled OPENCV source code, all LIB files will be installed in the/usr/local directory
Cmake-d cmake_build_type=release-d cmake_install_prefix=/usr/local
This place actually takes a long time, there may be errors, I have been very smooth here, I can not give specific measures, sorry.
Installation
Make
sudo make install
The environment variable Pkg_config_path provides a path query for the compile-time and run-time libraries. Pkg-config is a. pc file provided by the library to obtain all the necessary information about the library, including version information, compile and link required parameters, etc. This information can be extracted separately from the parameters provided by Pkg-config directly for use by the compiler and linker. Using the Pkg-config--cflags parameter gives you the options you need at compile time, while the--libs parameter gives you the option to link.
At the end of the installation of the above OpenCV, the Pkg-config read directory/usr/local/lib/pkgconfig/already has opencv.pc.
The above paragraph is quoted, and of course, a step is needed to modify the system environment variables
Editing environment variables
[Email protected]:~/downloads/opencv-2.4.1/build$ sudo vim/etc/ld.so.conf.d/opencv.conf
Add the path to the OPENCV library:
/usr/local/lib
[Email protected]:~/downloads/opencv-2.4.1/build$ sudo ldconfig
Add at the end:
Pkg_config_path= $PKG _config_path:/usr/local/lib/pkgconfigexport Pkg_config_path
The above is still the reference section, here, if there is no error, basically there is no problem. Don't take it lightly, there's something you need to do.
When we use g++ to compile, we need to pay attention to these points
g++ ' pkg-config opencv--cflags--libs opencv '-o test test.cpp-i/usr/local/include/opencv-l/usr/local/lib-lopenc V_core-lopencv_highgui-lopencv_imgproc-lopencv_objdetect -lopencv_imgcodecs
The above compile command, also from the reference, note two points:
1, ' Pkg-config opencv--cflags--libs OpenCV ' This thing, to have, no words, compile unsuccessfully.
The environment variable Pkg_config_path provides a path query for the compile-time and run-time libraries. Pkg-config is a. pc file provided by the library to obtain all the necessary information about the library, including version information, compile and link required parameters, etc. This information can be extracted separately from the parameters provided by Pkg-config directly for use by the compiler and linker. Using the Pkg-config--cflags parameter gives you the options you need at compile time, while the--libs parameter gives you the option to link.
2, to have a lot of linked files, otherwise the issue, the link file is located in the/usr/local/lib, OpenCV3.0.0 need to note is opencv_imgcodecs this link file, in other versions of the OpenCV no need, Here we must put it in, or there will be a problem.
The second part, the configuration of QT
If we follow the above content to configure, should not be a big problem.
QT configuration, mainly in the project file to add the following
includepath+=/usr/local/include\/usr/local/include/opencv\/usr/local/include/opencv2 LIBS+=/usr/local/lib/libopencv_highgui.so\/usr/local/lib/libopencv_core.so\/usr/local/lib/libopencv_imgproc.so\/usr/local/lib/libopencv_imgcodecs.so
As we can see, these are very similar to those in the shell using g++ compiled link libraries. In particular,/usr/local/lib/libopencv_imgcodecs.so a piece don't forget.
Quote the following information, thank you very much!!!
Http://blog.163.com/[email protected]/blog/static/171861983201311103411229/
http://www.douban.com/note/433807086/
Http://www.2cto.com/os/201404/291798.html
http://blog.csdn.net/WL2002200/article/details/45741635
Http://www.cnblogs.com/tornadomeet/archive/2012/07/10/2584702.html
OPENCV compilation under Linux and the use of OpenCV QT