gcc/g++ 10이 설치되었지만 Ubuntu 20.04.2 LTS에서는 사용할 수 없습니다.

gcc/g++ 10이 설치되었지만 Ubuntu 20.04.2 LTS에서는 사용할 수 없습니다.

여기 정보를 활용했어요Ubuntu 18.04에 g++ 10을 설치하는 방법은 무엇입니까?Ubuntu 20에 gcc/g++ 10을 설치하고 다시 시도하면 다음과 같습니다.

sudo apt install g++-10

Reading package lists... Done
Building dependency tree       
Reading state information... Done
g++-10 is already the newest version (10.2.0-5ubuntu1~20.04).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

하지만 버전을 물을 때:

g++ --version

g++ (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
Copyright (C) 2019 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++-10 --version

g++-10 (Ubuntu 10.2.0-5ubuntu1~20.04) 10.2.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++10이 설치되어 g++-10이라는 이름으로 사용 가능한 것 같지만 어떻게 기본 g++ 컴파일러로 만들 수 있나요?

답변1

update-alternatives기본적으로 사용해야 하는 g++ 버전을 지정하려면 를 사용해야 합니다 . 방법은 다음과 같습니다.

  1. 터미널 열기(아직 열려 있지 않은 경우)
  2. 구성 update-alternatives:
    sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-9 40
    sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-10 60
    sudo update-alternatives --config g++
    

마지막 명령을 실행하면 버전 메뉴가 표시되며 g++기본 버전을 선택할 수 있는 옵션이 제공됩니다 g++. 메시지는 다음과 같습니다.

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

메뉴에서 기본값으로 설정하려는 번호를 입력한 다음 를 누릅니다 Enter. g++나중에 기본 버전을 다시 변경해야 하는 경우 해당 명령을 다시 사용하십시오.

메모:gcc의 기본 버전도 변경해야 하는 경우 동일한 절차를 따르십시오. g++ ~와 함께 gcc.버전 번호도 변경하는 것을 잊지 마세요.

도움이 되었기를 바랍니다

관련 정보