MacOS – How to get the default compiler of c++ on Mac os x

gccmacosxcode

I am new in c++ on Mac os x and I need to know how to get some details:

  1. How to get the default compiler c++/c?
  2. How to change the default compiler?
  3. How to set the compiler in a CMakelists.txt file when using CMake?

Best Answer

You can just open terminal and type in gcc. If gcc is already installed on your mac then it will show as no input files. If you don't have gcc installed then you will get dialogue box saying you to download and install gcc and its respective command line tools. This method is prefered because install Xcode form the App Store take you time and as well as consumes your data (4.7GB). Since you need only gcc this is better because it even saves you disk space by installing you only gcc files. I hope this helps :-)