【问题标题】:Find the latest version of gcc and switch to it找到最新版本的 gcc 并切换到它
【发布时间】:2016-07-08 23:39:53
【问题描述】:

我在 Ubuntu 16.04 上安装了多个版本的 gcc,我想知道如何设置系统以使用最新版本的 gcc 而无需卸载旧版本。

我更喜欢它是一个简单的脚本而不是依赖项,因为我将它安装在 Docker 容器中并且我不想让它膨胀。

【问题讨论】:

标签: gcc g++


【解决方案1】:
# list everything in /usr/bin
# leave the ones that start with gcc
# remove everything but the version numbers
# remove anything but the numbers
# sort them
# get the last one
version=$(ls /usr/bin/ | grep '^gcc' | cut -d'-' -f2 | grep -o '[0-9]\+\(\.[0-9]\+\)\?' | sort | tail -n 1)

# remove the symbolic link to the current version of gcc
rm /usr/bin/gcc

# remove the symbolic link to the current version of g++
rm /usr/bin/g++

# create symbolic links to the latest versions
ln -s /usr/bin/g++-${version} /usr/bin/g++
ln -s /usr/bin/gcc-${version} /usr/bin/gcc

【讨论】:

    猜你喜欢
    • 2016-02-27
    • 2018-07-07
    • 1970-01-01
    • 2015-04-17
    • 1970-01-01
    • 1970-01-01
    • 2020-10-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多