Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

oat

macrumors newbie
Original poster
Nov 8, 2014
8
0
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:

/usr/bin (both files are 14kb) and
/Library/Developer/CommandLineTools/usr/bin (g++ is just an alias and gcc is 19kb)

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

Dargoth

macrumors regular
Oct 27, 2014
242
372
Currently, gcc and g++ in /usr/bin are what's known as shims. They are capable of automatically determining the path to their respective utilities, and then forwarding everything they receive to them. That path can either be the command line tools directory you mentioned above, or Xcode.
 

oat

macrumors newbie
Original poster
Nov 8, 2014
8
0
Thanks, Dargoth!

Does it mean, there's no need for frustration as the gcc and g++ in /usr/bin will forward whatever related to these two programs to the latest gcc and g++ installed via CommandLineTools in the system?
 

Dargoth

macrumors regular
Oct 27, 2014
242
372
Thanks, Dargoth!

Does it mean, there's no need for frustration as the gcc and g++ in /usr/bin will forward whatever related to these two programs to the latest gcc and g++ installed via CommandLineTools in the system?

Yep!
 

leman

macrumors Core
Oct 14, 2008
19,521
19,677
You might also want to check out the documentation for xcode-select

man xcode-select
 

Dargoth

macrumors regular
Oct 27, 2014
242
372
You might also want to check out the documentation for xcode-select

man xcode-select

Hah, I did leave that out didn't I. xcode-select is what determines what the shims point to. Thanks for the catch! :)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.