GCC(G++) 설치 및 관리
blog.koriel.kr/gcc-g-dareun-beojeon-cugahago-paekiji-gwanrihagi/
sudo apt install g++
여러개의 gcc 가 설치 되었을 때 확인 하는 명령어
sudo dpkg -l | grep gcc | awk '{print $2}'
얼터너티브 설정이 되어 있는지 확인 하는 명령어
sudo update-alternatives --display gcc
->update-alternatives: error: no alternatives for gcc (이런 결과가 나왔음)
설정이 안되어 있으면
sudo update-alternatives --install
arguments meaning
link 실행 파일의 이름으로 /etc/alternatives/을 가리킨다. (예: /usr/bin/gcc)
name 해당 링크 그룹의 대표 이름으로, 여러 가지 버전의 패키지들을 대표하는 이름으로 보면 된다.
(예: gcc)
path alternatives로 실제 연결할 실행 파일의 이름으로, 시스템에 설치한 패키지의 실행 파일 이름이다.
(예: /usr/bin/gcc-4.4)
priority automatic 모드에서 어떤 것을 자동으로 선택해서 사용할지 결정할 때 사용되는 우선순위로,
높은 수가 더 높은 우선순위이다.
아래와 같이 두 줄 실행 시키면 두 버전의 gcc를 alternatives에 등록
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 40
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 20
sudo update-alternatives --config gcc
설정하고자 하는 패키지의 인덱스 넘버를 입력한 후 엔터키를 치면 해당 버전으로 전환된다.
gcc 됐다고 g++ 까지 된것은 아닌듯 하다...
sudo update-alternatives --display g++
로 확인 해서 안되어 있으면 아래 수행
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-8 40
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-9 20
update-alternatives --config g++
sudo update-alternatives --display g++ 로 확인