Ubuntu下配置VScode的C++编程环境,ubuntuvscode
分享于 点击 4565 次 点评:190
Ubuntu下配置VScode的C++编程环境,ubuntuvscode
/# 1、安装VScode
直接从官网下载源码包,解压后即可使用
2、安装必要的开发环境
包括:gcc、g++、gdb、build-essential、Clang
3、安装必要插件
目前安装的插件如下:
1. C/C++
2. C/C++ Clang Command Adapter
3. C++ Intellisense
4. ClangComplete
5. Code Runner
6. makrdownlint
7. native Debug
8. ue4-cpptools
9. Auto-Open Markdown Preview
4、编写markdown文件
直接新建文件后保存为.md后缀文件即可
5、编译调试C/C++代码
编译的快捷键是:Ctrl+Shift+B
不过需要配置launch.json文件和tasks.json文件才能正常调试,否则可能会出现无法设置断点等问题。
launch.json文件可通过在“调试”窗口中点击齿轮状按钮进行配置,下面是一个样例:
{
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceRoot}/a.out",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceRoot}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
tasks.json需要通过以下方式添加配置:
1. Ctrl+P调出命令窗;
2. 在命令窗中输入“>tasks”,选择”Configure Task Runner“;
3. 选择“others”,打开tasks.json文件;
4. 进行配置,样例如下:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "0.1.0",
"command": "g++", //c++-g++ c-gcc
"isShellCommand": true,
"args": ["-g","${workspaceRoot}/hello.cpp"], //-g for debug
"showOutput": "always"
}
配置好这两个文件后就可以先使用Ctrl+Shift+B编译程序,再使用F5等调试方法调试程序。
相关文章
- 暂无相关文章
用户点评