I am new in c++ on Mac os x and I need to know how to get some details:
- How to get the default compiler c++/c?
- How to change the default compiler?
- How to set the compiler in a CMakelists.txt file when using CMake?
Ask Different is a question and answer site for power users of Apple hardware and software. It only takes a minute to sign up.Sign up to join this community
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 :-)
I don't think Mac come with a C/C++ compiler by default anymore. I recommend that you install XCode and XCode commandline tools from the App Store. That will give you the gcc compiler (and probably LLVM as well).
Without knowing your build process, I can't tell you how to set a default compiler. There will be an option in XCode as well as options with command-line build tools. IOW, Macs do not have a system-wide default compiler setting that I'm aware of.
Here's the official documentation on how to use a different compiler with CMake. https://gitlab.kitware.com/cmake/community/wikis/FAQ#how-do-i-use-a-different-compiler