2024-06-20|閱讀時間 ‧ 約 24 分鐘

在Ubuntu 24.04|22.04|20.04|18.04 安裝切換GCC編譯器

    安裝
    sudo apt update
    sudo apt upgrade
    ​sudo apt install g++-12 gcc-12
    sudo apt install g++-11 gcc-11

    驗證安裝​
    gcc-12 --version

    成功訊息​
    gcc-12 (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0
    Copyright (C) 2022 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 update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 100 --slave /usr/bin/g++ g++ /usr/bin/g++-12 --slave /usr/bin/gcov gcov /usr/bin/gcov-12

    sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 80 --slave /usr/bin/g++ g++ /usr/bin/g++-11 --slave /usr/bin/gcov gcov /usr/bin/gcov-11


    ​檢查預設
    gcc --version

    已經更改為12
    gcc (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0
    Copyright (C) 2022 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 update-alternatives --config gcc​




    分享至
    成為作者繼續創作的動力吧!
    © 2024 vocus All rights reserved.