4

I share a server (Ubuntu 11.04) with other people and I am the only one who has to use gcc 4-4 for my code, the rest is using 4.5. I already installed gcc 4.4 but how do I make it the default for me, without disturbing the others?

The solution needs to work for Makefiles and such.

I tried jw013's idea, but I think I screwed up. I created the symlink with ln -s /usr/bin/gcc-4.4 ~/bin/gcc and now my .bashrc won't load again. Here are the error messages:

Command 'lesspipe' is available in the following places
 * /bin/lesspipe
* /usr/bin/lesspipe
The command could not be located because '/usr/bin:/bin' is not included in the PATH environment variable.
lesspipe: command not found
Command 'dircolors' is available in '/usr/bin/dircolors'
The command could not be located because '/usr/bin' is not included in the PATH environment variable.
dircolors: command not found
Command 'uname' is available in '/bin/uname'
The command could not be located because '/bin' is not included in the PATH environment variable.
uname: command not found
-bash: [: =: unary operator expected
Command 'sed' is available in '/bin/sed'
The command could not be located because '/bin' is not included in the PATH environment variable.
sed: command not found
Command 'ls' is available in '/bin/ls'
The command could not be located because '/bin' is not included in the PATH environment variable.
ls: command not found
  • 1
    Looks like you screwed up your $PATH. Did you change that recently? – jw013 Oct 7 '11 at 18:46
  • 1
    I think I added export PATH="$HOME/bin" to my .bashrc. I am not sure, but removed the line after the errors and tried source .bashrc which did not help. :/ – Framester Oct 7 '11 at 19:05
  • 2
    That line you added wiped out your other PATH values which explains all the errors. .bashrc is not the correct place to change $PATH because it is sourced on every new shell. You should do that in .profile. 2. Most default .profiles I've seen already include a if [ -d "$HOME/bin" ]; then PATH="$HOME/bin:$PATH"; fi. If yours doesn't you can just add it. – jw013 Oct 7 '11 at 19:09
  • Okay, how can I repair my PATH values? My now corrected .bashrc and .profile only return these above errors. – Framester Oct 7 '11 at 19:20
  • 1
    For a really clean environment, log out and back in after you've fixed your files. – jw013 Oct 7 '11 at 19:24
6

The easiest method I can think of is to make a ~/bin directory inside your $HOME, add a symlink ~/bin/gcc to /usr/bin/gcc-4.4 or wherever your gcc-4.4 is located, and make sure ~/bin is at the beginning of your $PATH like this:

export PATH=~/bin:$PATH
0

You could define an alias. Add this to your ~/.bashrc file:

alias gcc='/usr/bin/gcc-4.4'

It would do the trick but it's a little hackish. I would recommend using jw013's symlink method.

  • This seems easier, but I still get an error message when running the Makefile stating that gcc4.5 is unsupported. – Framester Oct 7 '11 at 18:16
  • 4
    Aliases are only useful to you if you compile from the command line. If you're compiling from a Makefile, it won't be enough. – rahmu Oct 7 '11 at 18:22
0

follow the 3 steps

1.open /etc/profile

2.edit it with the following content

PATH=PATH:/usr/bin:/bin
export PATH

3.$source /etc/profile

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.