Compile OpenCv2.4.9 program under Ubuntu12.04

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.