How to move GCC in osx from xcode to /usr/bin
I 开发者_运维百科have the gcc compiler in "/Developer/usr/bin/gcc" but when i type in gcc into terminal it says can not be found, i assume this is because its not in the "/usr/bin" dir. So can i a) move gcc from the first dir to the second, or set some kind of shortcut pointing gcc to "/Developer/usr/bin/gcc"
The tip thewoolleyman linked to worked for me! I have installed Xcode 4.3.3 via the App Store. I did not have to install Xcode "again", seems Apple solved that. What I had to do are the following easy steps:
- Open Xcode
- Go To Preferences > Downloads
- Install the Command Line Tools
Thanks to Guy and his post https://stackoverflow.com/a/9377095/1451903
Two choices:
- Edit your
~/.bashrc
or~/.bash_profile
(or equivalent system files) and add/Developer/usr/bin/gcc
to$PATH
:export PATH="$PATH:/Developer/usr/bin/"
- Create a link (symlink in this example) in your
/usr/bin
directory pointing to the real file:ln -s /Developer/usr/bin/gcc /usr/bin/gcc
Note: in XCode 4.5 on MacOS 10.8 the path is now: /Applications/Xcode.app/Contents/Developer/usr/bin
Use ln -s
to create a symlink in /usr/bin
, or add /Developer/usr/bin
to $PATH
.
You can, in theory, hardlink it to the proper place.
The official way to do this is to install the optional "command-line tools" with the XCode installer. This wastes several hundred megabytes as it installs a new copy of the same compiler.
I wrote a shell script once to compare the installation trees of the "XCode" installation and the "command-line" installation and hardlink together all the files that were identical. It worked perfectly but the next upgrade undid it.
Another alternative is to download the GCC source from their CVS (not much bigger than downloading the massive XCode installer), and build it into usr/bin/
yourself. Then you have the latest and greatest (or your choice of many newer and better versions) to play with.
If you have "installed" Xcode from the App Store, check out this thread:
Mac OS X Lion Xcode problems using RVM
Apparently, "installing" Xcode from the app store doesn't actually install it, you must manually run the installer (search for "Install Xcode" in spotlight).
精彩评论