當(dāng)系統(tǒng)同時(shí)存在gcc-9以及gcc-10時(shí)該如何切換讓當(dāng)前的系統(tǒng)gcc版本指向gcc-9或是gcc-10呢?g++也同樣如此。
面臨更嚴(yán)重問題的python更是如此,ubuntu 目前默認(rèn)安裝的python版本是2.7,而我們經(jīng)常使用的版本為3.xx。
1 安裝gcc/g++/python
同時(shí)安裝gcc/g+±9,gcc/g+±10,python2/3文章來源:http://www.zghlxwxcb.cn/news/detail-753768.html
sudo apt-get install update
sudo apt install gcc-9
sudo apt install g++-9
sudo apt install gcc-10
sudo apt install g++-10
sudo apt install python
sudo apt install python3
2 設(shè)置gcc/g++/python的備選項(xiàng)
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 9
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 10
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-9 9
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-10 10
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 1
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 2
3 選擇當(dāng)前系統(tǒng)要使用的gcc/g++/python版本
3.1 切換gcc/g++/python版本
sudo update-alternatives --config gcc
sudo update-alternatives --config g++
sudo update-alternatives --config python
3.2 切換示例
以gcc為例文章來源地址http://www.zghlxwxcb.cn/news/detail-753768.html
$ sudo update-alternatives --config gcc
[sudo] password for test:
There are 2 choices for the alternative gcc (providing /usr/bin/gcc).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/bin/gcc-10 10 auto mode
* 1 /usr/bin/gcc-10 10 manual mode
2 /usr/bin/gcc-9 9 manual mode
Press <enter> to keep the current choice[*], or type selection number: 0
$
到了這里,關(guān)于ubuntu 20.04如何切換gcc/g++/python的版本的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!