Notice
Recent Posts
Recent Comments
Link
«   2025/05   »
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
Tags
more
Archives
Today
Total
관리 메뉴

main

[Ubuntu] gcc/g++ 버전별 설치 (update-alternatives 사용) 본문

ETC

[Ubuntu] gcc/g++ 버전별 설치 (update-alternatives 사용)

1984 2022. 6. 2. 22:53
repository 추가 및 package 설치
// repository 추가
sudo add-apt-repository ppa:ubuntu-toolchain-r/test&&\
sudo apt-get update

// 필요한 버전 설치
sudo apt-get install g++-4.9 gcc-4.9
sudo apt-get install g++-5 gcc-5
sudo apt-get install gcc-7 g++-7
sudo apt-get install gcc-8 g++-8
sudo apt-get install gcc-9 g++-9
sudo apt-get install gcc-11 g++-11
alternatives 설정 및 확인
// alternatives 삭제
sudo update-alternatives --remove-all gcc 
sudo update-alternatives --remove-all g++

// alternatives 설정 - 최신 버전을 높은 우선순위로 설정 (변경가능)
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 49
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.9 49

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 50
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-5 50

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 70
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 70

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 80
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-8 80

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 90
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-9 90

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 110
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-11 110

// alternatives 확인 및 변경
sudo update-alternatives --config gcc
sudo update-alternatives --config g++
728x90
Comments