On the mac the g++ compiler is disguised as clang. Here is a simple way to change it
Check to see if you have g++ installed by typing in the terminal:
g++ --version
If you have no made any changes it is most likely the clang version of g++
- Install g++ through [homebrew](https://brew.sh) or xcode.
- If Using homebrew type in the following to install:
- Check out the version you just installed, probably 12th or higher
- Now you need to make a symbolic link from g++-12 to g++ (this is for being able to call g++-12 with just typing g++). In order to do it, just type in your terminal:
Now open a new terminal and check your version again and you should see g++ instead of clang
If that does not work try typing out the entire path where g++ is on your machine
brew install gcc
g++ --version
sudo ln -s $(which g++-12) /usr/local/bin/g++
sudo ln -s /opt/homebrew/bin/g++-12 /usr/local/bin/
sudo ln -s pathSource pathDestination creates a symbolic link from pathSource to pathDestination.
$(which g++-12) returns the path for the command g++-12
This works for gcc as well