I'm a new to C++ and I'm using VSCode for the IDE.The system I use is WSL. I installed the GCC(11 and 12) from Homebrew in the wsl system. After I configured
task and tried to run the task, I got the error of as: unrecognized option '--gdwarf-5'.
The task.json is:
            "type": "cppbuild",
            "label": "Build with GCC 11.3.0",
            "command": "/home/linuxbrew/.linuxbrew/bin/g++-11",
            "args": [
                "-g",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": "build",
            "detail": "compiler: /home/linuxbrew/.linuxbrew/bin/g++-11"
        }
As you can see there's a "-g" in the args, while the compiler is from homebrew. It will give me the error as: unrecognized option '--gdwarf-5'.
But when I delete the argument "-g", it will build successfully.
However, when I use the GCC 9 which is not installed by hombrew, the task.json is :
{
            "type": "cppbuild",
            "label": "Build with GCC 9.4.0",
            "command": "/bin/g++",
            "args": [
                "-g",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": "build",
            "detail": "compiler: /bin/g++"
        }
As you can see there's also a "-g" in the arges, while the compiler is not from homebrew. And there's no error when building with the "-g"
It's super confusing for me, I guess it could because of the GCC path? But in the tutorial I am watching it is totally fine with the "-g" using the GCC 11 from Homebrew.
(And I have another question, Why VScode can't find the GCC 12 I installed from Homebrew?
)
Thank you for any help!