vscode配置C环境
-
win11安装MinGW
-
进入github
-
下载压缩包
-
直接解压后移动到指定目录,配置环境变量
Path=C:\Program Files\mingw64\bin
- 验证
C:\Users\dogle>gcc --version
gcc (x86_64-win32-seh-rev0, Built by MinGW-W64 project) 12.2.0
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
C:\Users\dogle>g++ --version
g++ (x86_64-win32-seh-rev0, Built by MinGW-W64 project) 12.2.0
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
C:\Users\dogle>gdb --version
GNU gdb (GDB) 11.2
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
- 安装vscode,安装插件
C/C++
C/C++ Extension Pack
Code Runner
- 新建文件test.c,使用vscode打开
#include <stdio.h>
int main()
{
/* 我的第一个 C 程序 */
printf("Hello, World! \n");
return 0;
}
-
点击右下角配置MinGW的g++路径,参考
-
查看配置
"C_Cpp.default.compilerPath": "c:\\Program Files\\mingw64\\bin\\g++.exe",
-
点击右上角调试,生成test.exe
-
点击右上角执行
输出
[Running] cd "d:\workspaces\" && gcc test.c -o test && "d:\workspaces\"test
Hello, World!
[Done] exited with code=0 in 0.538 seconds