您的位置:首页 > 运维架构 > Linux

linux下配置vscode 调试c++ 项目

2017-09-28 15:25 806 查看
每一个博客都是从坑里跳出啦的跳后感!!!

vscode 下调试c++项目:

配置 launch.json:

//launch.json

{

“version”: “0.2.0”,

“configurations”: [

{

“name”: “C++ Launch”,

“type”: “cppdbg”,

“request”: “launch”,

“program”: “${workspaceRoot}/Test.out”, //lookout!!!!

“args”: [],

“stopAtEntry”: false,

“cwd”: “${workspaceRoot}”,

“environment”: [],

“externalConsole”: true,

“preLaunchTask”: “g++”, //lookout!!!!

“linux”: {

“miDebuggerPath”: “/usr/bin/gdb”, //lookout!!!!

“MIMode”: “gdb”,

“setupCommands”: [

{

“description”: “Enable pretty-printing for gdb”,

“text”: “-enable-pretty-printing”,

“ignoreFailures”: true

}

]

}

}

]

}

配置 tasks.json:

{

// See https://go.microsoft.com/fwlink/?LinkId=733558

// for the documentation about the tasks.json format

“version”: “0.1.0”,

“command”: “g++”, //这里将”echo”修改为“g++”

“isShellCommand”: true,

“args”: [ //这里是编译参数,和 编译命令 中参数一一对应就行了

“-g”, //生成调试信息

“workspaceRoot/Test.cpp”,//源文件一“{workspaceRoot}/speak.cpp”, //源文件二(可省略)

“-o”, //编译参数

“${workspaceRoot}/Test.out” //生成的目标文件(编译文件),其名字要与调试配置文件:launch.json中的名字相同

],

“showOutput”: “always”

}

注意:

每一个工程都的配置一下, 就是重新写一个makefile文件一样!!!不爽也得写,这比makefile文件好写多啦!!!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: