如題,我照著VScode的官網教學(https://code.visualstudio.com/docs/cpp/config-mingw )一步一步做(我的編譯器用g++),也確定都有做到,但就是發生了下面的問題,我有試著在c_cpp_properties.json加入iostream的路徑,但問題仍然沒有解決QQ
問題的照片
c_cpp_properties.json檔案
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**",
"D:/msys64/mingw64/include/c++/12.1.0/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"compilerPath": "D:/msys64/mingw64/bin/g++.exe",
"cStandard": "gnu17",
"cppStandard": "gnu++17",
"intelliSenseMode": "windows-gcc-x64"
}
],
"version": 4
}
可以參考這一篇的步驟
https://hackmd.io/@liaojason2/vscodecppwindows
我猜測樓主應該是為尚未安裝MinGw與設定相關環境設定,設定完應該就可以在VSCODE上撰寫C++
可能是由於編譯器無法找到 iostream 的標頭檔所導致的。請嘗試修改您的 launch.json 檔案,加入下列引數:
"-I${workspaceFolder}"
這個引數將會告訴編譯器在工作區根目錄中尋找標頭檔。
修改後的 launch.json 應該長得像這樣:
{
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/a.out",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "D:/msys64/mingw64/bin/gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: g++ build active file",
"miDebuggerArgs": "-I${workspaceFolder}"
}
]
}