Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

Clarification

The solution needs to work for Makefiles and such.

Update

I tried jw013 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 wont 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
share|improve this question
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
add comment

2 Answers

up vote 4 down vote accepted

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
share|improve this answer
    
Thanks for your help! –  Framester Oct 7 '11 at 19:34
add comment

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.

share|improve this answer
    
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
2  
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
    
+1 for the explanation –  Framester Oct 7 '11 at 18:24
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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