2016-07-08 6 views
0

私はUbuntu 16.04に複数のバージョンのgccをインストールしましたが、古いバージョンをアンインストールせずにgccの最新バージョンを使用するようにシステムを設定する方法は不思議です。gccの最新バージョンを見つけてそれに切り替えてください

私はDockerコンテナにインストールしているので、それが単純なスクリプトであり、依存性ではない場合、私はそれを膨らませたくありません。

+0

[GCCの複数バージョンの使用方法](http://stackoverflow.com/questions/448457/how-to-use-multiple-versions-of-gcc) – Pyves

答えて

0
# 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 
関連する問題