本文共 2395 字,大约阅读时间需要 7 分钟。
之前写的细节方面还是有点问题——2020.7.3更
进入网站后不要点击 "Download Lasted Version"
,往下滑,找到最新版
的 "x86_64-posix-seh"
下载。
按下win+r,出现运行窗口,输入cmd
输入g++,回车,会有两种反馈
提示:'g++' 不是内部或外部命令,也不是可运行的程序或批处理文件。
C/C++
插件并下载code_test
文件夹。然后打开vscode,打开这个文件夹code_test
文件夹中新建一个 test.cpp
文件test.cpp
文件中输入一份简易的测试代码:#include#include int main(){ printf("Hello VScode!\nHello C++\n"); system("pause"); return 0;}
C++(GDB/LLDB)
,再选择g++.exe
。launch.json
文件,粘贴上下面的代码:"miDebuggerPath"
需要改成MinGW的路径,其他应该可以不用改){ // 使用 IntelliSense 了解相关属性。 // 悬停以查看现有属性的描述。 // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "name": "g++.exe - 生成和调试活动文件", "type": "cppdbg", "request": "launch", "program": "${fileDirname}\\${fileBasenameNoExtension}.exe", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "externalConsole": true,//小黑窗 "MIMode": "gdb", "miDebuggerPath": "D:\\2Software\\mingw64\\bin\\gdb.exe", "setupCommands": [ { "description": "为 gdb 启用整齐打印", "text": "-enable-pretty-printing", "ignoreFailures": true } ], "preLaunchTask": "g++.exe build active file" } ]}
test.cpp
文件,按下ctrl+F5,应该会出现下图,点击配置任务,tasks.json
文件,粘贴下面代码:{ "tasks": [ { "type": "shell", "label": "g++.exe build active file", "command": "D:\\2Software\\mingw64\\bin\\g++.exe", "args": [ "-g", "${file}", "-o", "${fileDirname}\\${fileBasenameNoExtension}.exe" ], "options": { "cwd": "D:\\2Software\\mingw64\\bin" } } ], "version": "2.0.0"}
转载地址:http://ueod.baihongyu.com/