方法1:基于cmake编译
1.一个CMakeLists.txt
cmake_minimum_required(VERSION 2.8)
project( DisplayImage )
add_executable( DisplayImage DisplayImage.cpp )
find_package( OpenCV REQUIRED )
include_directories( ${OpenCV_INCLUDE_DIRS} )
target_link_libraries( DisplayImage ${OpenCV_LIBS} )
- 在当前文件夹命令: cmake .
形成编译文件 - 编译命令 make
产生一个 可应用文件 DisplayImage - 输入 ./DisplayImage
方法2
打开 工作文件夹
编写.cpp .h
ctrl shift d 打开lauch.json
ctrl shift p 打开tasks.json
这个版本的和”name”: “g++ – Build and debug active file”,对应
………………………………………………………………………….
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
“version”: “2.0.0”,
“tasks”: [
{
“label”: “echo”,
“type”: “shell”,
“command”: “echo Hello”
},
{
“type”: “shell”,
“label”: “g++ build active file”,
“command”: “/usr/bin/g++”,
“args”: [
“-g”,
“${file}”,
“-o”,
“${fileDirname}/${fileBasenameNoExtension}”
],
“options”: {
“cwd”: “/usr/bin”
},
“problemMatcher”: [
“$gcc”
],
“group”: “build”
}
]
}
……………………………………………………………..
调试
默认生成a.exe程序