인디노트

Linux - update-alternatives - gcc 예제 본문

개발 플랫폼 및 언어

Linux - update-alternatives - gcc 예제

인디개발자 2019. 3. 15. 16:12

gcc, g++ 모든 항목 제거

root@dev:~# update-alternatives --remove-all gcc

root@dev:~# update-alternatives --remove-all g++



제거 확인

root@dev:~# update-alternatives --config gcc

update-alternatives: error: no alternatives for gcc


root@dev:~# update-alternatives --config g++

update-alternatives: error: no alternatives for g++



실행파일 찾지 못함

root@dev:~# gcc

-bash: /usr/bin/gcc: No such file or directory

root@dev:~# g++

-bash: /usr/bin/g++: No such file or directory



gcc-8, g++-8 설치

root@dev:~# apt-get install gcc-8 g++-8



등록

update-alternatives --install <link> <name> <path> <priority>


root@dev:~# update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 50 --slave /usr/bin/g++ g++ /usr/bin/g++-8

update-alternatives: using /usr/bin/gcc-8 to provide /usr/bin/gcc (gcc) in auto mode



버전 확인

root@dev:~# gcc --version

gcc (Ubuntu 8.2.0-1ubuntu2~18.04) 8.2.0

Copyright (C) 2018 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.


root@dev:~# g++ --version

g++ (Ubuntu 8.2.0-1ubuntu2~18.04) 8.2.0

Copyright (C) 2018 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.



config

root@dev:~# update-alternatives --config gcc

There is only one alternative in link group gcc (providing /usr/bin/gcc): /usr/bin/gcc-8

Nothing to configure.



gcc 4.8, g++ 4.8 설치

root@dev:~# apt-get install gcc-4.8 g++-4.8


4.8 버전을 순위값 40 으로 등록

root@dev:~# update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 40 --slave /usr/bin/g++ g++ /usr/bin/g++-4.8



gcc 리스트

root@dev:~# update-alternatives --list gcc

/usr/bin/gcc-4.8

/usr/bin/gcc-8


config

root@dev:~# update-alternatives --config gcc

There are 2 choices for the alternative gcc (providing /usr/bin/gcc).


  Selection    Path              Priority   Status

------------------------------------------------------------

* 0            /usr/bin/gcc-8     50        auto mode

  1            /usr/bin/gcc-4.8   40        manual mode

  2            /usr/bin/gcc-8     50        manual mode


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

update-alternatives: using /usr/bin/gcc-4.8 to provide /usr/bin/gcc (gcc) in manual mode



선택된 버전 확인


root@dev:~# gcc --version

gcc (Ubuntu 4.8.5-4ubuntu8) 4.8.5

Copyright (C) 2015 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.


root@dev:~# g++ --version

g++ (Ubuntu 4.8.5-4ubuntu8) 4.8.5

Copyright (C) 2015 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.


config

root@dev:~# update-alternatives --config gcc

There are 2 choices for the alternative gcc (providing /usr/bin/gcc).


  Selection    Path              Priority   Status

------------------------------------------------------------

  0            /usr/bin/gcc-8     50        auto mode

* 1            /usr/bin/gcc-4.8   40        manual mode

  2            /usr/bin/gcc-8     50        manual mode


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

update-alternatives: using /usr/bin/gcc-8 to provide /usr/bin/gcc (gcc) in auto mode



버전 확인

root@dev:~# gcc --version

gcc (Ubuntu 8.2.0-1ubuntu2~18.04) 8.2.0

Copyright (C) 2018 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.


root@dev:~# g++ --version

g++ (Ubuntu 8.2.0-1ubuntu2~18.04) 8.2.0

Copyright (C) 2018 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.

반응형

'개발 플랫폼 및 언어' 카테고리의 다른 글

CentOS 7 Cross Compiler  (0) 2019.03.15
Linux - update-alternatives - ARM 추가  (0) 2019.03.15
Linux - update-alternatives  (0) 2019.03.15
UFW Firewall on Ubuntu/Debian  (0) 2019.03.15
Ubuntu 16.04 system service 등록하기  (0) 2019.03.15
Comments