I installed GNU GCC on macos Ventura using homebrew, it installed g++12. It is installed at /opt/homebrew/Cellar/gcc/12.2.0
I tried to write basic c++ program and tried to run/debug it in vscode using their c/c++ plugin. Here is my program
#include<iostream>
using namespace std;
int main(int argc, char const *argv[])
{
std::cout << "Hello world!";
return 0;
}
My vscode tasks.json is like this
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++ build active file",
"command": "/opt/homebrew/bin/g++-12",
"args": [
"-std=c++17",
"-stdlib=libc++",
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
],
"version": "2.0.0"
}
If I change the configuration to use /usr/bin/g++ ("command": "/usr/bin/g++") instead of gnu gcc, everything works good.
But if I am using above configuration, vscode shows "iostream: No such file or directory" error
In both the cases if I am compiling form commandline it works.
What need to be chagned in vscode configuration?