1.头文件找不到
基本不用改多少东西
找不到头文件是因为c_cpp_properties.json中includepath你没有修改为你安装的mingw或者其他编译器的头文件和库的位置
2.大多编译失败都是gcc、gdb、g++没有加入环境变量(或者在tasks.json和launch.json文件中没有修改下图带有文字注释的地方):
tasks.json
代码:
"tasks": [ {
"type": "cppbuild",
"label": "C/C++: g++.exe build active file", "command": "C:\\msys64\\mingw32\\bin\\g++.exe",
/*这里是g++的位置,编译器的gcc、gdb、
g++都需要加入环境变量pash中,
大多问题都是这三个没有加入环境变量, */
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build"
"isDefault": true
},
"detail": "Task generated by Debugger."
} ],
"version": "2.0.0"
launch.json
代码:
{
"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": "c:\\msys64\\mingw32\\bin\\gdb.exe", /*这里是gdb的位置,编译器的
gcc、gdb、g++都需要加入环境变量pash中,
大多问题都是这三个没有加入环境变量, */ "setupCommands": [ {
"description": "为 gdb 启用整齐打印",
"text": "-enable-pretty-printing", "ignoreFailures": true}
],
"preLaunchTask": "C/C++: g++.exe build active file" } ]}
我遇到的就这俩问题,如果有其他问题欢迎留言
乐意效劳(其实我会的也就这点)但是我愿意解决其他可能遇到的问题