当前位置:网站首页>Vscode one click compilation and debugging
Vscode one click compilation and debugging
2022-07-29 04:27:00 【CAir2】
In this paper, the reference :vscode One click configuration C/C++ Multiple C And CPP File compilation and tasks.json and launch.json principle
Last article we learned about VScode How it works , But the actual project must be composed of multiple source files and modules . At this time, you can use the CMake Conduct configuration Engineering , Then proceed make compile .
In the last article, we know VScode The working principle of depends mainly on the execution of tasks , namely task.json. adopt CMake For the configured project, we only need to execute the following instructions , You can complete the compilation of the whole project .
CMake . && make
Realize the idea
- To write CMake Script
- function CMake Script generation makefile, And then execute make Compile the file .
CMake The output directory is still :build. So the task is mainly divided into two steps : The first step is to create Build Catalog , The second step is Build Directory execution CMake Instructions :CMake ../
establish build Catalog
{
"type":"shell",
"label": "mkBuild",
"command":"mkdir",
"args": [
// Here you need to specify parameters p, Otherwise, if build If the directory exists, the task will report an error
"-p",
"build"
],
"options": {
"cwd": "${workspaceFolder}"
},
},
stay build Directory execution CMake
{
"type":"shell",
"label": "executeCmake",
"command":"cmake",
"args": [
"../",
],
"options": {
"cwd": "${workspaceFolder}/build"
},
// Here you need to specify the dependent tasks mkBuild, from mkBuild establish build Catalog
"dependsOn":"mkBuild"
},
stay build Directory execution make
{
"type":"shell",
"label": "execMake",
"command":"make",
"args": [
],
"options": {
"cwd": "${workspaceFolder}/build"
},
// rely on CMake Mission
"dependsOn":"executeCmake"
}
At this time in launch.json Assigned tasks inside execMake that will do .
"preLaunchTask": "execMake",
After configuration, press run F5 Just debug , If debugging is required CMake It must be specified set(CMAKE_BUILD_TYPE "Debug"), Otherwise, it will not be debugged .
Here is the complete configuration file :task.json
{
"tasks": [
{
"type":"shell",
"label": "mkBuild",
"command":"mkdir",
"args": [
"-p",
"build"
],
"options": {
"cwd": "${workspaceFolder}"
},
},
{
"type":"shell",
"label": "executeCmake",
"command":"cmake",
"args": [
"../",
],
"options": {
"cwd": "${workspaceFolder}/build"
},
"dependsOn":"mkBuild"
},
{
"type":"shell",
"label": "execMake",
"command":"make",
"args": [
],
"options": {
"cwd": "${workspaceFolder}/build"
},
"dependsOn":"executeCmake"
}
],
"version": "2.0.0"
}
launch.json
{
// Use IntelliSense Learn about properties .
// Hover to see the description of an existing property .
// For more information , Please visit : https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "g++ - Generate and debug active files ",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/hellow",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}/build",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": " by gdb Enable neat printing ",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "execMake",
"miDebuggerPath": "/usr/bin/gdb"
}
]
}
because CMakeLists.txt The code of is not universal , So I won't post it here for the time being . If you don't understand CMake You can refer to : Article to read CMake
边栏推荐
- Exception handling: pyemd or pyemd not found
- C语言力扣第61题之旋转链表。双端队列与构造循环链表
- 9. Delay queue
- Code or script to speed up the video playback of video websites
- Methods of using multiple deformations on an element
- C语言:浅谈各种复杂的声明
- Fuzzy query of SQL
- TypeError: Cannot read properties of undefined (reading ‘then‘)
- Pytorch fixed random seed & recurrence model
- The third ACM program design competition of Wuhan University of Engineering
猜你喜欢

Not for 63 days. The biggest XOR

Code or script to speed up the video playback of video websites

Why are there so many unknowns when opengauss starts?

Record of problems encountered in ROS learning

Realize the effect of univariate quadratic equation through JS. Enter the coefficients of a, B and C to calculate the values of X1 and x2

不会就坚持66天吧 权重生成随机数

Won't you just stick to 62 days? Sum of words

不会就坚持65天吧 只出现一次的数字

不会就坚持67天吧 平方根

String, array, generalized table (detailed)
随机推荐
MySQL - 深入解析MySQL索引数据结构
Laya中的A星寻路
How to query the submission number of a version
顺序表和链表
Object detection: object_ Detection API +ssd target detection model
Semantic segmentation correlation
Fuzzy query of SQL
Deploy Jenkins using containers
The principle of inverse Fourier transform (IFFT) in signal processing
全屋WiFi方案:Mesh路由器组网和AC+AP
Niuke IOI weekly 27 popularity group
VScode 一键编译和调试
12. Priority queue and inert queue
[common commands]
Kotlin's list, map, set and other collection classes do not specify types
[material delivery UAV] record (ROS + Px4 + yolov5 + esp8266 + steering gear)
The function "postgis_version" cannot be found when installing PostGIS
Update learning materials daily
Dabao and Erbao
【Express连接MySQL数据库】