Linux C ++ development and compilation simple process

Take the simplest program in Ubuntu involving the opencv library as an example:

1. Coding: writing C ++ programs. For example: test_a.cpp

2. Connection: Create a new CMakeLists.txt, for example: 

cmake_minimum_required(VERSION 2.8)
project(test_a)
find_package(OpenCV REQUIRED)
add_executable(test_a test_a.cpp)
target_link_libraries(test_a ${OpenCV_LIBS})

The meaning of each line:

2.1 Specify the lowest cmake version

2.2. Project name

2.3 Find a package

2.4 Generate executable files. The executable file name corresponds to the source code name

2.5 Link library files

 

3. Compile and generate an executable file: test_a

$ cmake .
$ make

4. Run

$ ./test_a

 

Published 202 original articles · 80 praised · 300,000 views +

Guess you like

Origin blog.csdn.net/qxqxqzzz/article/details/105118937