点击上方
“
小白学视觉
”,选择加"
星标
"或“
置顶
”
重磅干货,第一时间送达

VS code 插件配置手册
C/C++ Tools插件---C/C++支持
安装
库文件的配置
GDB本地调试配置
GDB远程调试配置
Remote VSCode插件---远程编辑文件
安装
环境配置
在本地端的配置
在远程端的配置
工作流
Ftp Sync插件--—远程代码的同步
安装
环境配置
工作流
此扩展的预览版本为C / C ++添加了对Visual Studio Code的语言支持,包括:
语言服务:
-
代码格式(clang格式)
-
自动补全
-
符号搜索
-
签名帮助
-
快速信息
-
转到定义/声明
-
查看定义/声明
-
类/方法导航
调试:
在VSCode的扩展插件中找到C/C++插件并进行安装;
Windows下想开发Linux代码需要安装Mingw开发工具
打开项目到工作区,
按F1打开命令行,输入:
open settings json
选择Preferences:Opem Settings (JSON),打开settings.json文件
在settings.json文件中添加:
/*****C/C++ Tools*****/
"C_Cpp.autocomplete"
: "Default",
"[cpp]": {
"editor.quickSuggestions": true
},
"[c]": {
"editor.quickSuggestions": true
},
"C_Cpp.default.cStandard": "c11",
"C_Cpp.default.cppStandard": "c++11",
/*****C/C++ Tools*****/
按F1打开命令行,输入:
edit configuration json
选择C/C++:Edit configurations (JSON),打开c_cpp_properties.json文件
在settings.json文件中添加:
{
"configurations": [
{
"name": "system", //系统类型
"includePath": [ //头文件目录,**表示匹配目录文件及子目录
"${workspaceFolder}/**"
],
"defines": [],
"compilerPath": "path", //编译器地址
"intelliSenseMode": "mode" //编译器类型
"cStandard": "c11",
"cppStandard": "c++11"
}
],
"version": 4
}
如:
Windows :
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**",
"C:/opencv/build/include/opencv2/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"intelliSenseMode": "msvc-x64",
"cStandard": "c11",
"cppStandard"
: "c++11"
}
],
"version": 4
}
Linux:
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"intelliSenseMode": "clang-x64",
"cStandard": "c11",
"cppStandard": "c++11"
}
],
"version": 4
}
打开项目到工作区,
打开侧栏的“调试”界面->点击“设置”按钮,选择C++(GDB/LLDB)选项:
打开launch.json文件,在文件中添加:
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch", // 配置名称,将会在启动配置的下拉菜单中显示
"type": "cppdbg", // 配置类型,不需修改
"request": "launch", // 请求配置类型,可以为launch(启动)或attach(附加)
"program": "${workspaceFolder}/bin文件", // 将要进行调试的程序的路径
"args": [], // 程序调试时传递给程序的命令行参数,["arg1", "arg2].
"stopAtEntry": false, // 设为true时程序将暂停在程序入口处,一般设置为false
"cwd": "${workspaceFolder}", // 程序调试程序时要搜索的代码的目录
"additionalSOLibSearchPath": "path" // 程序调试程序时要搜索的.so文件的目录(选填)
"environment": [], // 针对调试的程序,要添加到环境中的环境变量(选填)
"externalConsole": true, // 调试时是否显示控制台窗口,一般设置为true显示控制台
"MIMode": "gdb", // VSCode要使用的调试工具,必须设置为gdb或lldb
"
miDebuggerPath": "path", // VSCode要使用的调试工具路径(需要绝对路径)
"preLaunchTask": "g++", // 调试开始前执行的任务,需要配置tasks.json文件(选填)
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
如:
Windows:
{
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program":"${workspaceRoot}/bin/pthread.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "C:\\MinGw\\bin\\gdb.exe"
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
Linux:
{
"version": "0.2.0",
"configurations": [
{
"name": "(gdb local) L",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/bin/pthread",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"externalConsole": true,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
打开侧栏的“调试”界面->点击“开始调试”按钮,开始调试
GDB远程调试配置
打开项目到工作区,
打开侧栏的“调试”界面->点击“设置”按钮,选择C++(GDB/LLDB)选项:
打开launch.json文件,在文件中添加:
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch", // 配置名称,将会在启动配置的下拉菜单中显示
"type"