Statement: This article is personal according to the relevant blog information plus their own experience to organize, in this share for everyone to learn to communicate!
Assuming that the codeblocks under the CentOS system is already installed, we will compile the OPENCV under the CentOS platform and develop the test under Codeblocks.
(1) Download OpenCV source code, and compile and install
Currently the latest version is OpenCV-2.2 and can be downloaded from http://sourceforge.net/projects/opencvlibrary/.
There are two ways to compile OpenCV, one is traditional./configure; make; Make install, this method applies to OpenCV-1.0, the corresponding compilation process can be see this article: http://www.opencv.org.cn/index.php/%E6%BA%90%E7%A0%81%E7%BC%96% E8%af%91, another way is to use CMake. ; make; Make install, this method is suitable for opencv-2.x. Therefore, before compiling the OpenCV-2.2, you have to install CMake (http://www.cmake.org/) on the CentOS first.
(1.1) Compile and install CMake:
Suppose cmake-2.8.4.tar.gz put it in/root/software/cmake-2.8.4.tar.gz.
Cd/root/software/
Tar zxvf cmake-2.8.4.tar.gz
Compiling and installing CMake
Download CMake Source package cmake-2.8.4.tar.gz,mv to/usr/local/src directory
[Email protected] ~]# cd/usr/local/src/
[Email protected] src]# tar xzvf cmake-2.8.7.tar.gz
[Email protected] src]# CD cmake-2.8.7
[Email protected] cmake-2.8.4]#./bootstrap
---------------------------------------------
CMake 2.8.4, Copyright 2000-2009 Kitware, Inc.
---------------------------------------------
Error when bootstrapping CMake:
Cannot find appropriate C compiler on the This system.
Please specify one using environment variable CC.
See Cmake_bootstrap.log for compilers attempted.
---------------------------------------------
Log of errors:/usr/local/src/cmake-2.8.4/bootstrap.cmk/cmake_bootstrap.log
---------------------------------------------
Error: C compiler is missing.
Installing the GCC compiler
Can be installed from the installation disk of a Linux system, or can be easily installed with Yum
[[email protected] ~]# Yum install gcc
Continue with CMake installation
[Email protected] cmake-2.8.4]#./bootstrap
---------------------------------------------
CMake 2.8.4, Copyright 2000-2009 Kitware, Inc.
C compiler on the This system IS:CC
---------------------------------------------
Error when bootstrapping CMake:
Cannot find appropriate C + + compiler on the This system.
Please specify one using environment variable CXX.
See Cmake_bootstrap.log for compilers attempted.
---------------------------------------------
Log of errors:/usr/local/src/cmake-2.8.4/bootstrap.cmk/cmake_bootstrap.log
---------------------------------------------
Error again: the C + + compiler is missing.
Installing the Gcc-c++ Compiler
It can also be installed from the installation disk of a Linux system, or simply with Yum
[email protected] ~]# Yum install gcc-c++
Repeat the above action
[Email protected] cmake-2.8.4]#./bootstrap
After no error, compile and install
[Email protected] cmake-2.8.4]# Gmake
[[email protected] cmake-2.8.4]# gmake Install
(1.2) Compile and install opencv-2.2: (Note: If you need a graphics library, install gtk2.x first)
Suppose opencv-2.2.0.tar.bz2 put it in/root/software/opencv-2.2.0.tar.bz2.
Cd/root/software/
Tar jxvf opencv-2.2.0.tar.bz2
CD OpenCV-2.2.0
mkdir Release
CD release
CMake. /
Make
Make install
Error and resolution: HTTP://GAODR.BLOG.163.COM/BLOG/STATIC/10461500820134824949883/
1) Linking CXX executable. /.. /bin/opencv_perf_core
.. /.. /lib/libopencv_highgui.so.2.4.9:undefined reference to ' [email protected]_0 '
Solution: Modify the Cmakecache.txt,cmake_exe_linker_flags in the/opt/opencv2.3.1 directory to be empty, plus-lpng, such as:
If not, just use locate libpng to look at it, then delete everything related to libpng one by one, and reinstall the Libpng library.
Yum Remove libpng
Yum Install libpng
Yum Install Libpng-devel
There was a problem compiling freak.cpp:
Error: Could not find the available register in class ' General_regs '
After checking, it is related to compiling optimization parameter, find compile control file of compiling Freak.cpp
Flags.make and Link.txt, will
Compile optimization options from
-o3 instead
-o0
The error is resolved.
An error occurred: similar to C + +: Internal error:killed (program Cc1plus)
Workaround: CMake is using the following command
CMake. /-dcmake_c_flags_release= "-o1-dndebug"-dcmake_cxx_flags_release= "-o1-dndebug"
b) Error:
Linking CXX executable. /.. /bin/opencv_perf_core
.. /.. /lib/libopencv_highgui.so.2.4.5:undefined reference to ' PNG_SET_LONGJMP_FN '
COLLECT2:LD return 1
MAKE[2]: * * [Bin/opencv_perf_core] Error 1
MAKE[1]: * * [Modules/core/cmakefiles/opencv_perf_core.dir/all] Error 2
After checking, it is related to compiling libopencv_highgui.so.2.4.5 parameters, modifying the files that control compiling libopencv_highgui.so.2.4.5 link.txt
Then modify the compiled Pencv_perf_core file link.txt.
Are added or changed to:-lpng/usr/local/lib/libpng16.so
The error is resolved.
Cause: There are different versions of the Libpng.so library in the system, specifying the use of libpng16.so
(1.3) Setting environment variables
This step is the same as the purpose of Windows to set the system environment variables, telling the system where the binary files and library files are located.
cd/etc/ld.so.conf.d/
Vim opencv.conf
Write/usr/local/lib to file and save
Ldconfig
You can use locate LIBCV to view the location of the corresponding library files.
Export Pkg_config_path=/usr/local/lib/pkgconfig: $PKG _config_path
(2) Configuration OpenCV
See http://blog.csdn.net/dupei/archive/2011/05/18/6428283.aspx
After the configuration is complete, you can test with the test case. If executed successfully, the OPENCV configuration is complete.
The final step is to test whether the OpenCV library is available.
$ CD ~/opencv/samples/cpp
$ gcc-i/usr/local/include/opencv-l/usr/local/lib/-lopencv_highgui-lstdc++ Drawing.cpp-o Drawing
$./drawing
Error: OpenCV error:unspecified error (the function is not implemented. Rebuild the library with Windows, GTK + 2.x or Carbon support. If you is on Ubuntu or Debian, install Libgtk2.0-dev and pkg-config, then re-run cmake or configure script) in Cvnamedwin Dow, File/home/armmlinux/zdfwork/project/software/opencv-2.4.9/modules/highgui/src/window.cpp, line 483
FIX: Install gtk2.x
Http://www.jb51.net/article/22134.htm
GLib installation Tips GetText Problem Resolution: http://blog.csdn.net/ybdesire/article/details/7249896
Install Libffi Library: http://download.chinaunix.net/download/0006000/5819.shtml
Compiling the glib library is a report of errors like libgettext.so: http://blog.csdn.net/david_xtd/article/details/7625626
Obviously installed the library, also appeared similar: configure:error:Library requirements (glib-2.0 >= 2.4.0 ATK >= 1.0.1 Pango >= 1.4.0) not met; Consider adjusting the PKG_CONFIG_PATH environment variable if your libraries is in a nonstandard prefix so pkg-config CA N Find Them. The error: http://blog.csdn.net/ubuntulover/article/details/6978305
Compile, install, and configure OPENCV on the CentOS system