c++macosterminalg++clang++

clang: error: unknown argument: '-fno-leading-underscore'


I am trying to compile my .cpp with -fno-leading-underscore option but it raises an error saying:

clang: error: unknown argument: '-fno-leading-underscore'

g++ -m32 -fno-use-cxa-atexit -nostdlib -fno-builtin -fno-rtti -fno-exceptions -fno-leading-underscore -o kernel.o -c kernel.cpp

How can I fix this I am new to Mac it used to work on Linux Mint


Solution

  • In your terminal, type g++ and press enter. You will probably get:

    $ clang: No input files
    

    As you can see its still clang underneath.

    To fix this, first cd into /usr/local/bin and type ls. You will see the binaries inside:

    g++-9
    ...
    

    Next, create a symlink to it so that you can invoke g++ directly

    ln -s g++-9 g++
    

    If it still doesn't work for some reason, you can explicitly write g++-9 or whatever version you have. You can even give the full path /usr/local/bin/g++-9