当前位置:网站首页>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
边栏推荐
- 用 ZEGO Avatar 做一个虚拟人|虚拟主播直播解决方案
- Labelme cannot open the picture
- MySQL - clustered index and secondary index
- Semantic segmentation correlation
- The pit I walked through: the first ad Sketchpad
- LeetCode_ Stack topics
- Not for 63 days. The biggest XOR
- Laya中的A星寻路
- MySQL gets the maximum value record by field grouping
- Integration of Nan causes in pytorch training model
猜你喜欢

【Express连接MySQL数据库】

11. Backup switch

Not for 63 days. The biggest XOR

12.优先级队列和惰性队列

MySQL - deep parsing of MySQL index data structure

Don't stick to it for 68 days. Baboons eat bananas

Implementation of jump connection of RESNET (pytorch)

读懂 互联网巨头 【中台之战】 以及 中台 发展思维

Beginner: array & String

MySQL - 聚簇索引和辅助索引
随机推荐
Laya中的A星寻路
不会就坚持66天吧 权重生成随机数
【Express连接MySQL数据库】
Machine vision Series 2: vs DLL debugging
Don't stick to it for 68 days. Baboons eat bananas
Exception handling: pyemd or pyemd not found
MySQL - deep parsing of MySQL index data structure
DASCTF2022.07赋能赛
不会就坚持58天吧 实现前缀树
pyscript无法引入包
Down sampling and up sampling
12. Priority queue and inert queue
No, just stick to it for 59 days
Won't you just stick to 69 days? Merge range
不会就坚持67天吧 平方根
Implementation of jump connection of RESNET (pytorch)
Deep learning training strategy -- warming up the learning rate
Post export data, return
C语言:联合体知识点总结
Two forms of softmax cross entropy + numpy implementation