我的 Ubuntu 14.04 LTS 系统上安装了两个 gcc。通常在它们之间进行选择不会有问题,但其中一个的安装位置却令人困惑。
$ which gcc
/usr/bin/gcc
$ gcc --version
gcc (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ sudo apt-get install gcc-4.9
Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'sc-gcc-4.9.3' for regex 'gcc-4.9'
Note, selecting 'gcc-4.9-base' for regex 'gcc-4.9'
gcc-4.9-base is already the newest version.
sc-gcc-4.9.3 is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
$ /usr/local/gcc/4.9.3/bin/gcc --version
gcc (GCC) 4.9.3
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ ls -l /usr/bin | grep gcc
-rwxr-xr-x 1 root root 428 May 7 2006 c89-gcc
-rwxr-xr-x 1 root root 454 Apr 11 2011 c99-gcc
lrwxrwxrwx 1 root root 7 Apr 7 2014 gcc -> gcc-4.8
-rwxr-xr-x 1 root root 775888 May 7 2016 gcc-4.8
lrwxrwxrwx 1 root root 10 Apr 7 2014 gcc-ar -> gcc-ar-4.8
-rwxr-xr-x 1 root root 26968 May 7 2016 gcc-ar-4.8
lrwxrwxrwx 1 root root 10 Apr 7 2014 gcc-nm -> gcc-nm-4.8
-rwxr-xr-x 1 root root 26968 May 7 2016 gcc-nm-4.8
lrwxrwxrwx 1 root root 14 Apr 7 2014 gcc-ranlib -> gcc-ranlib-4.8
-rwxr-xr-x 1 root root 26968 May 7 2016 gcc-ranlib-4.8
lrwxrwxrwx 1 root root 7 Apr 7 2014 x86_64-linux-gnu-gcc -> gcc-4.8
lrwxrwxrwx 1 root root 7 May 7 2016 x86_64-linux-gnu-gcc-4.8 -> gcc-4.8
lrwxrwxrwx 1 root root 10 Apr 7 2014 x86_64-linux-gnu-gcc-ar -> gcc-ar-4.8
lrwxrwxrwx 1 root root 10 May 7 2016 x86_64-linux-gnu-gcc-ar-4.8 -> gcc-ar-4.8
lrwxrwxrwx 1 root root 10 Apr 7 2014 x86_64-linux-gnu-gcc-nm -> gcc-nm-4.8
lrwxrwxrwx 1 root root 10 May 7 2016 x86_64-linux-gnu-gcc-nm-4.8 -> gcc-nm-4.8
lrwxrwxrwx 1 root root 14 Apr 7 2014 x86_64-linux-gnu-gcc-ranlib -> gcc-ranlib-4.8
lrwxrwxrwx 1 root root 14 May 7 2016 x86_64-linux-gnu-gcc-ranlib-4.8 -> gcc-ranlib-4.8
$ apt-cache policy sc-gcc-4.9.3
sc-gcc-4.9.3:
Installed: 1-20160726
Candidate: 1-20160726
Version table:
*** 1-20160726 0
500 http://usa-mirror.internal.net/mirrors/stable/3rdparty/trusty/ ./ Packages
100 /var/lib/dpkg/status
因此 apt-get 知道 gcc-4.9 已安装,但我不确定为什么它最终位于 /usr/local/gcc/4.9.3/bin 而不是 /usr/bin。
有人能对此提供一些见解吗?如何更新链接的最佳做法是什么?