ソフトウェア管理の複数のバージョンのUbuntuの

https://linuxize.com/post/how-to-install-gcc-compiler-on-ubuntu-18-04/

sudo apt install software-properties-common
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
コピー

タイピングすることにより、所望のGCCとG ++バージョンをインストールします。

sudo apt install gcc-7 g++-7 gcc-8 g++-8 gcc-9 g++-9
コピー

以下のコマンドは、バージョンごとに選択肢を設定し、それに優先順位を関連付けます。デフォルトのバージョンである我々の場合には、最も優先順位の高いものですgcc-9

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 90 --slave /usr/bin/g++ g++ /usr/bin/g++-9 --slave /usr/bin/gcov gcov /usr/bin/gcov-9
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 80 --slave /usr/bin/g++ g++ /usr/bin/g++-8 --slave /usr/bin/gcov gcov /usr/bin/gcov-8
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 70 --slave /usr/bin/g++ g++ /usr/bin/g++-7 --slave /usr/bin/gcov gcov /usr/bin/gcov-7
コピー

デフォルトのバージョンを変更したい場合は、後で使うupdate-alternativesコマンドを:

sudo update-alternatives --config gcc
コピー
There are 3 choices for the alternative gcc (providing /usr/bin/gcc).

  Selection    Path            Priority   Status
------------------------------------------------------------
* 0            /usr/bin/gcc-9   90        auto mode
  1            /usr/bin/gcc-7   70        manual mode
  2            /usr/bin/gcc-8   80        manual mode
  3            /usr/bin/gcc-9   90        manual mode

Press <enter> to keep the current choice[*], or type selection number:
コピー

あなたのUbuntuシステムにインストールされているすべてのGCCのバージョンの一覧が表示されます。あなたがデフォルトとプレスとして使用したいバージョンの番号を入力しますEnter

コマンドが作成されますシンボリックリンク GCCとG ++の特定のバージョンにします。

 

おすすめ

転載: www.cnblogs.com/lightsong/p/11839284.html