3

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? enter image description here)

Thank you for any help!

Adam Qi
  • 41
  • 3
  • 3
    Weren't all these fancy GUI IDEs and editors, like VSCode, with their pretty dialogs and buttons, supposed to make things easier, to avoid all these yucky `Makefile`s and command lines? You mean that you have to invoke some magic incantation in the form of a convoluted JSON configuration file, to get basic functionality right? That's a darn shame, isn't it? After reading `make`s man page, as lengthy as it is, with plenty of examples, it's always pretty straightofrward for me to simply push `F5` in emacs, and get everything built. – Sam Varshavchik Oct 09 '22 at 13:55
  • @SamVarshavchik • lol, that's the dream. The dream falls a bit short of the reality. – Eljay Oct 09 '22 at 14:12
  • 2
    Please don't post images of text (code). Post actual *text* instead. – Jesper Juhl Oct 09 '22 at 15:51
  • @SamVarshavchik I wouldn’t call vs code an IDE, personally, nothing is integrated about it at all. Everything is bolt-on. – Taekahn Oct 09 '22 at 18:11
  • @Taekahn I'll take everything-bolted-on over everything-(jb)welded-on-and-painted-over-to-hide-the-evidence any day of the week. – n. m. could be an AI Oct 09 '22 at 21:58
  • 1
    @n.1.8e9-where's-my-sharem. Ok….? It wasn’t some sort of judgement call or me trying to promote _the one true IDE_ . I actually like the minimalist approach. People should use whatever development environment they prefer. I just don’t think we should get into the habit of calling everything used to write code an IDE. While there is no absolute definition of the word, I personally believe that an ide should provide a full development environment out of the box. – Taekahn Oct 09 '22 at 22:32
  • @Jesper Juhl Thank you for reminding me, images are replaced by the real codes. – Adam Qi Oct 10 '22 at 06:56
  • Duplicate of https://stackoverflow.com/q/74000991/1983398? – ssbssa Oct 10 '22 at 10:32
  • @ssbssa Thanks. It could be a similar question. I tried to update the Binutils but my Binutils version is already up-to-date (version: 2.39_1), anything I could do other than that? (Also tried reinstall the Binutils, doesn't work) – Adam Qi Oct 10 '22 at 13:14
  • But do you maybe still have an older binutils version around which gcc is using? – ssbssa Oct 10 '22 at 13:32
  • @SamVarshavchik there are better build systems than "make" (I'm using AdaCore gprbuild for C/C++ and Ada), but I admit I never got VS code to work properly. Yes, they moved the problem from well-known makefiles to another microsoft convoluted thingy. I don't believe in editors that can handle all languages & compilers either. Too generic means lots of configuration and lots of possible errors – Jean-François Fabre Nov 17 '22 at 22:55
  • @AdamQi was this case solved somehow? – Слава ЗСУ Dec 23 '22 at 10:52

0 Answers0