Reputation: 484
I just had a fresh re-installation of Mac OS X Yosemite before I install Xcode and then CommandlineTools.
It seems I have two versions of gcc and g++ in the following two directories:
Type "which gcc" in the Terminal gives me "/usr/bin/gcc", so did "which g++" which gives me "/usr/bin/g++", and this means the system will only use the gcc and g++ in /usr/bin
So, my questions are:
1. why do I have two versions of gcc and g++?
2. why the gcc and g++ installed with CommandLineTools is not specified as the default ones?
3. How do I ask the Mac OS X to point to the gcc and g++ in the directory "/Library/Developer/CommandLineTools/usr/bin"?
BTW, i installed CommandlineTools according to the following:
http://railsapps.github.io/xcode-command-line-tools.html
However, I got a different output by typing "gcc --version" (difference hightlighted):
Configured with: --prefix=/Application/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1 Apple LLVM version 6.0 (clang-600.0.54) (based on LLVM 3.5svn) Target: x86_64-apple-darwin14.0.0 Thread model: posix
... rather than /Library/Developer/CommandLineTools/usr as shown in the web page above ...
I'm quite confused about which gcc/g++ is actually being used by Mac OSX currently ...
Upvotes: 3
Views: 1146
Reputation: 3225
Basically when you call 'cc' or 'cxx' or 'c++' you are calling clang. Read here for more information about the state of Apple clang (https://developer.apple.com/library/mac/documentation/CompilerTools/Conceptual/LLVMCompilerOverview/)
Adding to what @adnan-kamili said, you may wonder why Apple did that. So here is a short answer from Llia Lebedev (https://www.quora.com/Compilers-Why-did-Apple-create-Clang)
A factor in their decision may certainly have been GCC's license. GPL is highly restrictive when it comes to non-free software. Specifically, GPL requires derivative projects to be provided with their full and open source, also licensed under GPL.
While a reasonable course of action available to Apple would be to dedicate a handful of smart engineers to beef up GCC's support for everything Apple, the license would require their work to be to be released under GPL as well - a tricky proposition within a large corporation, as it would likely force significant amounts of Apple software hooking into GCC to be released under GPL also.
Clang was open-sourced under the much more permissive University of Illinois License, which allows Apple to develop private branches of Clang without releasing full source code.
Upvotes: 1
Reputation: 9465
Mac OSX doesn't use gcc (g++). It defaults to Clang since Mac OSX 10.7. So when you type gcc or g++ to compile it actually uses Clang (cc)
Upvotes: 2