Reference address http://blog.163.com/[email protected]/blog/static/171861983201311103411229/
Method 1: direct command compilation:
G+ + main. CPP -o main ' pkg-config--cflags--libs opencv ' (note ESC below ', not single quotes)
Method 2: With CMake, you need to write CMakeLists.txt, examples are as follows:
Cmake_minimum_required(VERSION 2.8)
project (hello)
find_package(OpenCV REQUIRED) add_executable(Hello main. ) CPP) target_link_libraries(Hello ${opencv_libs})
And then:
CMake .
Make
Previously, only GCC was used, but g++ was not used, and the difference between the two was known by the way.
GCC and g++ are the GNU C & C + + compilers gcc/g++ in a total of 4 steps ⒈ preprocessing to generate. i file [preprocessor Cpp]⒉ converts the preprocessed file into assembly language and generates the file. s[compiler Egcs]⒊ by assembly variable Generate. o Files for Target code (machine code) [Assembler As]⒋ connect target code, generate executable program [linker LD]
Details: Http://wenku.baidu.com/link?url=3XEota_ G9vavzgf2ggjltlhggiwtkhqlu-3yyjuwoavvvdnvuygpuvrpnmgzxatusz8errww8gkj6jvqseywblo2jzlpdtis-lpxxd4_keg
Compile OpenCv2.4.9 program under Ubuntu12.04