Reputation: 352
I needed to use OpenMP and Xcode command line tools come with gcc version 4.2.something so I wanted to upgrade to gcc version 4.8. I have gcc4.8 installed. I did this -
$ sudo rm /usr/bin/gcc /usr/bin/g++
$ sudo ln -s /usr/bin/gcc /usr/bin/gcc-4.8
Similar link for g++. Now there IS a gcc link created in /usr/bin. I can see gcc in /usr/bin when I do $ ls -la /usr/bin
and I can also see the correct symlink when I do
$ ls -la /usr/bin | grep gcc
It points to gcc-4.8.
However, the system simply ignores gcc. It is as if it doesn't exist there. /usr/bin is in my PATH variable. However, gcc [tab complete] does not show up.
$ gcc
-bash: gcc: command not found
Compiling any C program now uses cc located in /usr/bin/cc. I don't get it. I simply removed the current symlink gcc had with xcode CLTools and made a new one. What did I do wrong considering I really did very little?
Thank you.
Upvotes: 0
Views: 3443
Reputation: 16728
Your syntax to create the symbolic link is incorrect: the first argument to ln
is where you want the link to point to.
sudo ln -s /usr/bin/gcc-4.8 /usr/bin/gcc
From the man page for ln
:
SYNOPSIS
ln [-Ffhinsv] source_file [target_file]
ln [-Ffhinsv] source_file ... target_dir
This is slightly confusing, as "source" and "target" could be interpreted either way (i.e. is target_file
the target of the link or the target of the ln
command?). The man page later clarifies this:
Given one or two arguments, ln creates a link to an existing file source_file. If target_file is given, the link has that name; target_file may also be a directory in which to place the link; otherwise it is placed in the current directory. If only the directory is specified, the link will be made to the last component of source_file.
Upvotes: 1