VS Code c++环境安装 实测有效

时间:2024-04-07 10:41:28

今天又花了5,6个小时只为了搭建一个环境, 网上的做法人云亦云,配了好久还是配不明白,为了不让更多人浪费时间,受着鸟气,我绝对要写一下做.
1 下载mingw 文件类型是seh
x86_64-8.1.0-release-posix-seh-rt_v6-rev0.7z
链接https://nchc.dl.sourceforge.net/project/mingw-w64/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/8.1.0/threads-posix/seh/x86_64-8.1.0-release-posix-seh-rt_v6-rev0.7z
把zip解压到文件之后
win10的操作
设置系统环境变量( 右键我的电脑 +R ) ->高级系统设置->环境变量-> 下面的系统变量里的Path编辑 新增一个
VS Code c++环境安装 实测有效
配置成功标志 win +r 输入cmd
输入gcc有红字 输入gcc -v有版本号VS Code c++环境安装 实测有效
2 下载Vs code
下载地址:https://code.visualstudio.com/Download
里面的过程我省略了
引用一下别人的吧
https://blog.csdn.net/qq_40969864/article/details/103158635?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.channel_param&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.channel_param
此帖子有效

其中按下 F5 可能会发生的错误
1 VScode配置C++环境,preLaunchTask"g++"已终止,退出代码为

解决办法
建议 重新配置 lauch.json tasks.json c_cpp_properties.json
目前还不知道问题出现在哪里,
可能1
tasks.josn中
错误配置:
“command”: “D:\Microsoft VS Code\MinGW64\bin\g++.exe”,
正确配置:
“command”: "g++.exe

2 使用VScode 调试的时候提示 Unable to start debugging. Unexpected GDB output from command “-environment -cd xxx” No such file or

原因 文件目录出现中文名 改掉名字再来试一试

3 使用VScode 调试的时候提示 Unable to start debugging. Launch options string provided by the project system is invalid. Unable to determine path to debugger. Please specify the “MIDebuggerPath” option.

原因 miDebuggerPath 出错了
查看lanch.json 检查是否少了斜杠
经过调试 路径可以用\ 或者/之间连接, 不用在意一定要\