티스토리 뷰
반응형
CentOS8 (RHEL 8)은 gcc/g++의 8 버전으로 repo에 등록되어있습니다.
gcc/g++8에서 C++17까지 사용할 수 있으나, C++ 최신 버전인 C++20을 사용하려면 gcc/g++9를 별도로 설치해 주어야 합니다. (2022년 3월 3일 기준)
CentOS8에서 gcc/g++9를 설치하는 방법을 알아보겠습니다.
먼저 패키지를 최신으로 업데이트합니다.
$ sudo yum update
업데이트 시도시 Failed to download ... 관련 오류가 발생된다면 아래 글을 참조하세요.
CentOS8 Failed to download metadata for repo 'appstream' 오류 해결
CentOS8은 2021년 12월 31일부로 EOS 변경되어 Stream을 변경해야 지원을 받을 수 있습니다. yum update 또는 install시, Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mir..
bundw.tistory.com
패키지를 설치합니다.
$ sudo yum install -y gcc-toolset-9-gcc gcc-toolset-9-gcc-c++
설치가 완료되면 profile에 source /opt/rh/gcc-toolset-9/enable를 추가하여 활성화(PATH 등록)를 합니다.
$ vi ~/.bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
source /opt/rh/gcc-toolset-9/enable
수정된 profile을 반영합니다.
$ source ~/.bash_profile
완료되었습니다. 정상적으로 설치되었는지 확인해 봅니다.
$ gcc --version
gcc (GCC) 9.2.1 20191120 (Red Hat 9.2.1-2)
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.
반응형
'SW개발 > C,C++' 카테고리의 다른 글
C++에서 C#의 Delegate처럼 Callback사용 (0) | 2022.10.24 |
---|---|
Ubuntu(우분투)20.04 gcc/g++10 설치 (Visual Studio Linux C++20 오류 해결) (0) | 2022.03.07 |