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" } ]}
我遇到的就這倆問題,如果有其他問題歡迎留言
樂意效勞(其實我會的也就這點)但是我願意解決其他可能遇到的問題