views:

37

answers:

3

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"

+1  A: 

Use ln -s to create a symlink in /usr/bin, or add /Developer/usr/bin to $PATH.

Ignacio Vazquez-Abrams
+3  A: 

Two choices:

  1. Edit your ~/.bashrc or ~/.bash_profile (or equivalent system files) and add /Developer/usr/bin/gcc to $PATH: export PATH="$PATH:/Developer/usr/bin/"
  2. 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
Slokun
Id go with the `.bash_*` edits. less possibility of issues than with the symlink.
prodigitalson
I can edit ~/.bash_profile , can you elaborate more on what i have to do please ? i dont want to screw up system files
kizzie33
@kizzie33 You'd need to either find where the `$PATH` variable is modified, or add the line `export PATH="$PATH:/Developer/usr/bin/"` (with quotes) to the end of the file. The ones in your home directory aren't system files (edited answer to clarify what I meant), so you wouldn't be breaking any other accounts if you made a mistake
Slokun
A: 

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.

Potatoswatter