Software-Installation

如何僅為一個使用者設置預設 gcc 版本?

  • May 25, 2018

我與其他人共享一台伺服器(Ubuntu 11.04),我是唯一一個必須為我的程式碼使用 gcc 4-4 的人,其餘的都使用 4.5。我已經安裝了 gcc 4.4,但是如何在不打擾其他人的情況下將其設為預設值?

該解決方案需要適用於 Makefiles 等。

我嘗試了 jw013 的想法,但我認為我搞砸了。我創建了符號連結,ln -s /usr/bin/gcc-4.4 ~/bin/gcc現在我.bashrc不會再次載入。以下是錯誤消息:

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

我能想到的最簡單的方法是在~/bin您的.$HOME``~/bin/gcc``/usr/bin/gcc-4.4``gcc-4.4``~/bin``$PATH

export PATH=~/bin:$PATH

您可以定義一個別名。將此添加到您的~/.bashrc文件中:

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

它會做的伎倆,但它有點hackish。我建議使用 jw013 的符號連結方法。

引用自:https://unix.stackexchange.com/questions/22263