Node.js 10.24 버전으로 빌드하기 위해 node-gyp를 이용하여 빌드하려고 한다. 그러나 다음과 같은 에러를 확인했다.
cc1plus: error: unrecognized command line option "-std=gnu++1y"
해당 버전이 C++ v11 를 사용해서 문제가 발생했다고 한다.(구글링)
따라서, gcc 4.8.2 이상 버전으로 업그레이드 하려고 한다.
먼저, CentOS 버전을 확인한다.
$ cat /etc/centos-release
CentOS release 6.9 (Final)
CentOS6.9 의 기본 GCC 버전은 4.4.7이다.
$ gcc --version
gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-18)
...
GCC 4.8 설치
# wget https://people.centos.org/tru/devtools-2/devtools-2.repo --no-check-certificate -O /etc/yum.repos.d/devtools-2.repo
# yum install devtoolset-2-gcc devtoolset-2-binutils
# yum install devtoolset-2-gcc-c++ devtoolset-2-gcc-gfortran
기본으로 GCC 4.8를 사용하도록 한다.
# scl enable devtoolset-2 bash
enable 스크립트를 적용
# source /opt/rh/devtoolset-2/enable
제대로 설치되었는지 확인한다.
$ gcc --version
gcc (GCC) 4.8.2 20140120 (Red Hat 4.8.2-15)
...
$ g++ --version
g++ (GCC) 4.8.2 20140120 (Red Hat 4.8.2-15)
[root@localhost ~]# yum install devtoolset-2-gcc
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Loading mirror speeds from cached hostfile
http://mirror.centos.org/centos/6/sclo/x86_64/rh/repodata/repomd.xml: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404 Not Found"
Trying other mirror.
To address this issue please refer to the below knowledge base article
https://access.redhat.com/articles/1320623
If above article doesn't help to resolve this issue please open a ticket with Red Hat Support.
Error: Cannot retrieve repository metadata (repomd.xml) for repository: centos-sclo-rh. Please verify its path and try again
제품의 수명이 끝났기때문에(EOL) 발생한 문제이다.
그러므로 yum으로 설치할때 default 로 “http://mirror.centos.org…” 주소를 참조하지 않도록 수정한다.
# cd /etc/yum.repos.d
# grep "mirror.centos.org" *
CentOS-SCLo-scl-rh.repo:baseurl=http://mirror.centos.org/centos/6/sclo/$basearch/rh/
CentOS-SCLo-scl.repo:baseurl=http://mirror.centos.org/centos/6/sclo/$basearch/sclo/
CentOS-fasttrack.repo:#baseurl=http://mirror.centos.org/centos/$releasever/fasttrack/$basearch/
하나씩 들어가서 enable=0으로 설정해준다.
vi CentOS-fasttrack.repo
vi CentOS-SCLo-scl.repo
vi CentOS-SCLo-scl-rh.repo