下载编译器MinGW并解压
官网页面:https://www.mingw-w64.org/
下载页面:https://sourceforge.net/projects/mingw-w64/files/
https://cmake.org/download/
需要环境变量进行设置
task.json:
{ "tasks": [ { "type": "cppbuild", "label": "C/C++: gcc.exe 生成活动文件", //和preLaunchTask一致 "command": "C:\\CU\\mingw64\\bin\\gcc.exe", //让g++执行 的.c文件变为.exe文件 "args": [ "-fdiagnostics-color=always", "-g", //调试的选项 "${file}", //当执行哪一个文件,编译器就解释那个文件。 "-finput-charset=UTF-8", "-fexec-charset=GBK", //解决输出中文问题 "-o", "${fileDirname}\\${fileBasenameNoExtension}.exe" //生成exe文件 ], "options": { "cwd": "${fileDirname}" }, "problemMatcher": [ "$gcc" ], "group": { "kind": "build", "isDefault": true }, "detail": "调试器生成的任务。" } ], "version": "2.0.0" }
lanuch.json:
{ "configurations": [ { "name": "C/C++: gcc.exe 生成和调试活动文件", //调试活动文件 "type": "cppdbg", //C++的配置类型 "request": "launch", "program": "${fileDirname}\\${fileBasenameNoExtension}.exe", //程序可执行文件的完整路径,启动exe文件 "args": [], "stopAtEntry": false, "cwd": "${fileDirname}", "environment": [], "externalConsole": true, // false为vscode的输出集成终端,true输出为系统的集成终端 "MIMode": "gdb", "miDebuggerPath": "C:\\CU\\mingw64\\bin\\gdb.exe", //调试器的路径 也就是解释器的路径 "setupCommands": [ { "description": "为 gdb 启用整齐打印", "text": "-enable-pretty-printing", "ignoreFailures": true }, { "description": "将反汇编风格设置为 Intel", "text": "-gdb-set disassembly-flavor intel", "ignoreFailures": true } ], "preLaunchTask": "C/C++: gcc.exe 生成活动文件" //在调试program生成exe文件,在tasks.json文件里执行,启动g++编译可执行程序。 } ], "version": "2.0.0" }
helloword.c
#include <stdlib.h> #include <stdio.h> #include <string.h> int main() { ////SetConsoleOutputCP(65001); printf("hello word\n"); printf("你好,中囯\n"); system("pause"); return 0; }
标签:文件,gcc,exe,vscode,C++,gdb,cpp,true From: https://www.cnblogs.com/geovindu/p/17691757.html