How to install the gcc compiler on a mac

Hi, I was just wondering, I have been learning c++ on a mac and I have no way to compile my code. I need to know how to install gcc on my MacBook.


1 Like

gcc on my mac was installed when I installed xCode from the AppStore:

SF:git sflanders95$ gcc --version
Configured with: --prefix=/Applications/ --with-gxx-include-dir=/Applications/
Apple LLVM version 10.0.0 (clang-1000.11.45.2)
Target: x86_64-apple-darwin17.7.0
Thread model: posix
InstalledDir: /Applications/
SF:git sflanders95$ which gcc

XCode in the AppStore Link (via itunes)  or 


1 Like

That’s actually Clang, not GCC. You could try using Homebrew.


if it “has” to be on the mac then xcode is probably the easiest - although I code using atom or visual studio code :slight_smile: not the xcode ide

xcode-select --install

in a mac terminal should get you where you need to be.

after install 

$ gcc --version
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/c++/4.2.1
Apple LLVM version 10.0.0 (clang-1000.10.44.4)
Target: x86_64-apple-darwin18.2.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

This is way more fun!

1 Like

Hello there, I am also using VScode for my cpp programming and facing some issues while using some new features from C++ 17. Do you have any suggestions to solve this issue ?
I am using microsoft’s C/C++ compiler extension.