Skip to content

williamrogersdev/clangtogcc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 

Repository files navigation

How to switch from clang to g++ on mac M1 and intel chip.

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++

Steps to Switch from clang to g++ on mac


  • Install g++ through [homebrew](https://brew.sh) or xcode.
  • If Using homebrew type in the following to install:
  • brew install gcc
    
  • Check out the version you just installed, probably 12th or higher
  • g++ --version
    
  • 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:
  • sudo ln -s $(which g++-12) /usr/local/bin/g++
    
  • 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

  • sudo ln -s /opt/homebrew/bin/g++-12 /usr/local/bin/
    

Explanation

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

About

How to switch from clang to g++ on mac M1 and intel chip

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published