1.安装好VScode 2.安装minGW 3.打开VSCODE,安装方框中的三个插件: 4.重新启动VScode 5.新建一个test.c文件,输入 #include <stdio.h> int main(){ printf("test for python"); getchar(); return 0; } 包含的头文件出会出现波浪线跟小灯泡(不知道怎么复现出来,因为我找不到去掉头文件配置东西),然后点那个小灯泡,会进入一个设置界面,将include path: D:\software\MinGW\include** D:\software\MinGW\lib\gcc\mingw32\9.2.0\include** D:\software\MinGW\lib\gcc\mingw32\9.2.0\include-fixed** 和编译路径: D:\software\MinGW\bin 这是我安装MINGW的路径 填上,似乎会生成一个c_cpp_properties.json ,我现在只在目录下看到setting.json文件。
6.新建文件launch.json:
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "C++ Launch (GDB)",
"type": "cppdbg",
"request": "launch",
"targetArchitecture": "x86",
"program": "${workspaceRoot}\\${fileBasename}.exe",
"miDebuggerPath":"D:\\software\\MinGW\\bin\\gcc.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceRoot}",
"externalConsole": true,
"preLaunchTask": "gcc"
}
]
}
7.新建文件tasks.json(注意上面文件中的preLaunchTask与下面的label要一致):
{
"version": "2.0.0",
"tasks": [
{
"type": "cppbuild",
"label": "gcc",
"command": "gcc",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": [
"$gcc"
],
"group": "build",
"detail": "编译器: D:\\software\\MinGW\\bin\\gcc.exe"
}
]
}
8.尝试点击调试运行按钮,我这边是编译成功了
|