ubuntu vscode c++配置

launch.json

{
    // 使用 IntelliSense 了解相关属性。 
    // 悬停以查看现有属性的描述。
    // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/a.out",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": true,
            "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": "2.0.0",
    "tasks": [
        {
            "label": "hello",
            "type": "shell",
            "command": "g++",
            "isShellCommand": true,
            "args": [
                "-g",
                "${workspaceFolder}/hello.cpp"
            ], //这边改成自己的工作目录。直接复制launch.json文件中即可
            //hello.cpp 是自己工作文件名字(一定要放在文件家夹中)
            "showOutput": "always"
        }
    ]
}

这两个文件均可以用模板生成

图片: 在这里插入图片描述在这里插入图片描述1、vscode的代码路径不能有中文,否则会出现无法跟踪代码定义的问题;
2、“externalConsole”: 应该为false,否则无法进入调试;fu
3、args为一个数组,而不是一个字符串
4、tasks.json的label为编译目标程序名称,必须与launch.json的"program": " w o r k s p a c e F o l d e r / {workspaceFolder}/ workspaceFolder/(programname)",中的$(programname)相同,否则调试将出问题。
5、“command”: "g++"为使用g++编译,对于c++源码,"gcc"为使用gcc编译,对应c源码,"make"对应makefile文件编译,源码工程目录下必须有对应makefile工程

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值