在ubuntu中 配置vscode 的 C++ 环境
安装C++环境
sudo apt install gcc
sudo apt install g++
配置vscode
点击左侧齿轮按纽,点击弹出窗口的齿轮按钮添加环境
然后点击设置会生成一个后缀为json的文件,将其中的内容修改为
{ // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "name": "(gdb) Launch", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/${fileBasenameNoExtension}.out", "args": [], "stopAtEntry": true, "cwd": "${workspaceFolder}", "environment": [], "externalConsole": false, "MIMode": "gdb", "preLaunchTask": "build", "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": "build", "type": "shell", "command": "g++", "args": ["-g", "${file}", "-std=c++11", "-o", "${fileBasenameNoExtension}.out"] } ] }
- 在同一文件夹下创建名为
这就配置好了,按f5就可以调试了