GCC Version Alternative

Peloton·2023년 10월 26일
0
post-thumbnail
post-custom-banner

Alternative를 사용해 GCC/G++ 등록

  • Terminal 실행

  • Check GCC Version
    대부분 GCC는 아마 "/usr/local" 또는 "/opt/" 아래에 위치해 있을 것입니다.
    gcc의 위치를 확인 후 gcc/g++를 등록합니다.
    마지막 숫자는 우선순위(priority)입니다. 어떤 숫자든 상관 없습니다.

    # sudo ./configure_gcc_alternatives.sh
    sudo update-alternatives --install /usr/bin/gcc gcc /usr/local/gcc-10.1.0/bin/gcc-10.1 10
    sudo update-alternatives --install /usr/bin/gcc gcc /opt/gcc-9.1.0/bin/gcc-9.1 20
    
    sudo update-alternatives --install /usr/bin/g++ g++ /usr/local/gcc-10.1.0/bin/g++-10.1 10
    sudo update-alternatives --install /usr/bin/g++ g++ /opt/gcc-9.1.0/bin/g++-9.1 20
    
    sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 30
    sudo update-alternatives --set cc /usr/bin/gcc
    
    sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 30
    sudo update-alternatives --set c++ /usr/bin/g++
  • 만약 업데이트가 완료되면 아래와 같이 출력됩니다.

    $ sudo ./configure_gcc_alternatives.sh
    update-alternatives: using /usr/local/gcc-10.1.0/bin/gcc-10.1 to provide /usr/bin/gcc (gcc) in auto mode
    update-alternatives: using /opt/gcc-9.1.0/bin/gcc-9.1 to provide /usr/bin/gcc (gcc) in auto mode
    update-alternatives: using /usr/local/gcc-10.1.0/bin/g++-10.1 to provide /usr/bin/g++ (g++) in auto mode
    update-alternatives: using /opt/gcc-9.1.0/bin/g++-9.1 to provide /usr/bin/g++ (g++) in auto mode

alternative를 사용하여 GCC/G++ 선택

GCC 선택

  • Command

    sudo update-alternatives --config gcc
  • Example

    $ sudo update-alternatives --config gcc
    There are 2 choices for the alternative gcc (providing /usr/bin/gcc).
    
      Selection    Path                                Priority   Status
    ------------------------------------------------------------
    * 0            /opt/gcc-9.1.0/bin/gcc-9.1           20        auto mode
      1            /opt/gcc-9.1.0/bin/gcc-9.1           20        manual mode
      2            /usr/local/gcc-10.1.0/bin/gcc-10.1   10        manual mode
    
    Press <enter> to keep the current choice[*], or type selection number: 2
    update-alternatives: using /usr/local/gcc-10.1.0/bin/gcc-10.1 to provide /usr/bin/gcc (gcc) in manual mode

G++ 선택

  • Command

    sudo update-alternatives --config g++
  • Example

    There are 2 choices for the alternative g++ (providing /usr/bin/g++).
    
      Selection    Path                                Priority   Status
    ------------------------------------------------------------
    * 0            /opt/gcc-9.1.0/bin/g++-9.1           20        auto mode
      1            /opt/gcc-9.1.0/bin/g++-9.1           20        manual mode
      2            /usr/local/gcc-10.1.0/bin/g++-10.1   10        manual mode
    
    Press <enter> to keep the current choice[*], or type selection number: 2
    update-alternatives: using /usr/local/gcc-10.1.0/bin/g++-10.1 to provide /usr/bin/g++ (g++) in manual mode

GCC/G++ Version 확인

아래 명령을 통해 버전을 확인합니다.

  • Command

    gcc --version
    g++ --version
  • Example

    $ gcc --version
    gcc (GCC) 10.1.0
    Copyright (C) 2020 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.
    
    $ g++ --version
    g++ (GCC) 10.1.0
    Copyright (C) 2020 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.
    
profile
Software Engineeeeer
post-custom-banner

0개의 댓글