centos7.4 어떻게 원본 설치 gcc 7.3.0

7764 단어
1. 환경:arm 구조의centos7.4 시스템 서버
2. 현재 gcc 버전 보기: gcc-v
[root@aarch64vm-centos74-011 ~]# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/aarch64-redhat-linux/4.8.5/lto-wrapper
Target: aarch64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-aarch64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-aarch64-redhat-linux/cloog-install --enable-gnu-indirect-function --build=aarch64-redhat-linux
Thread model: posix
gcc version 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC) 

3. gcc 7.3.0의 원본 코드를 다운로드합니다.https://mirrors.ustc.edu.cn/gnu/gcc/gcc-7.3.0/gcc-7.3.0.tar.gz
4. 원본을 서버에 업로드하고 압축을 풀기
[root@aarch64vm-centos74-010 ~]# mkdir -p /usr/local/gcc
[root@aarch64vm-centos74-010 ~]# ls /usr/local/
bin  boost  cmake  doc  etc  games  gcc  include  lib  lib64  libexec  man  maven  mysql  sbin  share  src  tomcat
[root@aarch64vm-centos74-010 ~]# ls
anaconda-ks.cfg                boost_1_59_0.tar.gz  jdk1.8.0_161                           mysql-5.7.19.tar.gz  spark-1.6.1-bin-without-hadoop.tgz
apache-maven-3.3.9-bin.tar.gz  cmake-2.8.5.tar.gz   jdk-8u161-linux-arm64-vfp-hflt.tar.gz  scala-2.11.7.tgz     spark-2.1.0-bin-hadoop2.7.tgz
apache-tomcat-8.0.53.tar.gz    gcc-7.3.0.tar.gz     mysql-5.7.19                           scala-2.12.6.tgz
[root@aarch64vm-centos74-010 ~]# tar -xvf gcc-7.3.0.tar.gz -C /usr/local/gcc/

5. 압축 해제 완료 후 설치 gcc 원본 코드 컴파일
(1) gcc 7.3.0 디렉터리에 들어가서 download_ 실행prerequisites 스크립트.
[root@aarch64vm-centos74-010 ~]# cd /usr/local/gcc/
[root@aarch64vm-centos74-010 gcc]# ls
gcc-7.3.0
[root@aarch64vm-centos74-010 gcc]# cd gcc-7.3.0/
[root@aarch64vm-centos74-010 gcc-7.3.0]# ls
ABOUT-NLS           config-ml.in  COPYING3         gnattools     libada        libffi       libitm         libstdc++-v3     lto-plugin          Makefile.in     NEWS
ChangeLog           config.rpath  COPYING3.LIB     gotools       libatomic     libgcc       libmpx         libtool-ldflags  ltoptions.m4        Makefile.tpl    README
ChangeLog.jit       config.sub    COPYING.LIB      include       libbacktrace  libgfortran  libobjc        libtool.m4       ltsugar.m4          MD5SUMS         symlink-tree
ChangeLog.tree-ssa  configure     COPYING.RUNTIME  INSTALL       libcc1        libgo        liboffloadmic  libvtv           ltversion.m4        missing         ylwrap
compile             configure.ac  depcomp          install-sh    libcilkrts    libgomp      libquadmath    ltgcc.m4         MAINTAINERS         mkdep           zlib
config              contrib       fixincludes      intl          libcpp        libhsail-rt  libsanitizer   ltmain.sh        maintainer-scripts  mkinstalldirs
config.guess        COPYING       gcc              LAST_UPDATED  libdecnumber  libiberty    libssp         lt~obsolete.m4   Makefile.def        move-if-change
[root@aarch64vm-centos74-010 gcc-7.3.0]# ./contrib/download_prerequisites
2018-07-18 16:06:03 URL: ftp://gcc.gnu.org/pub/gcc/infrastructure/gmp-6.1.0.tar.bz2 [2383840] -> "./gmp-6.1.0.tar.bz2" [1]
2018-07-18 16:08:29 URL: ftp://gcc.gnu.org/pub/gcc/infrastructure/mpfr-3.1.4.tar.bz2 [1279284] -> "./mpfr-3.1.4.tar.bz2" [1]
2018-07-18 16:09:25 URL: ftp://gcc.gnu.org/pub/gcc/infrastructure/mpc-1.0.3.tar.gz [669925] -> "./mpc-1.0.3.tar.gz" [1]
2018-07-18 16:12:42 URL: ftp://gcc.gnu.org/pub/gcc/infrastructure/isl-0.16.1.tar.bz2 [1626446] -> "./isl-0.16.1.tar.bz2" [1]
gmp-6.1.0.tar.bz2: OK
mpfr-3.1.4.tar.bz2: OK
mpc-1.0.3.tar.gz: OK
isl-0.16.1.tar.bz2: OK
All prerequisites downloaded successfully.
[root@aarch64vm-centos74-010 gcc-7.3.0]# 

(2) 컴파일 출력 디렉터리를 만들고 모든 중간 파일을 디렉터리에 넣습니다.
[root@aarch64vm-centos74-010 gcc-7.3.0]# mkdir gcc-build-7.3.0
[root@aarch64vm-centos74-010 gcc-7.3.0]# cd gcc-build-7.3.0/
[root@aarch64vm-centos74-010 gcc-build-7.3.0]# cp ../gmp-6.1.0.tar.bz2 ./
[root@aarch64vm-centos74-010 gcc-build-7.3.0]# cp ../mpfr-3.1.4.tar.bz2 ./
[root@aarch64vm-centos74-010 gcc-build-7.3.0]# cp ../mpc-1.0.3.tar.gz ./
[root@aarch64vm-centos74-010 gcc-build-7.3.0]# cp ../isl-0.16.1.tar.bz2 ./
[root@aarch64vm-centos74-010 gcc-build-7.3.0]# ls
gmp-6.1.0.tar.bz2  isl-0.16.1.tar.bz2  mpc-1.0.3.tar.gz  mpfr-3.1.4.tar.bz2
[root@aarch64vm-centos74-010 gcc-build-7.3.0]# 

(3) 구성:
현재 디렉토리에서 다음을 수행합니다.
           ../configure --enable-checking=release --enable-languages=c,c++ --disable-multilib 매개변수 해석:
--enable-checking=release//검사를 추가할 수도 있습니다 – disable-checking에서 생성된 컴파일러는 컴파일하는 과정에서 검사를 하지 않습니다.
--enable-languages=c, c++//gcc가 지원하는 프로그래밍 언어;
--disable-multilib//다목적 라이브러리 컴파일 취소(32비트 라이브러리 컴파일 취소).
(4)make 컴파일
현재 디렉터리 실행:make-j4
(번역 시간이 길고 기다려!!!!!!)
(5) 이전 버전의 gcc 마운트 해제, gcc7.3.0 설치
rpm -q gcc  rpm -q gcc-c++
실행 출력된 패키지 이름에 따라 실행rpm -e [ ]  
[root@localhost ~]# rpm -q gcc
gcc-4.8.5-28.el7_5.1.aarch64
[root@localhost ~]# rpm -q gcc-c++
gcc-c++-4.8.5-28.el7_5.1.aarch64
[root@localhost ~]# rpm -e gcc-c++-4.8.5-28.el7_5.1.aarch64
[root@localhost ~]# rpm -e gcc-4.8.5-28.el7_5.1.aarch64

make의 gcc 디렉터리에 들어가서 설치:make install-j8
(6) 검증
[root@localhost ~]# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/aarch64-unknown-linux-gnu/7.3.0/lto-wrapper
Target: aarch64-unknown-linux-gnu
Configured with: ../configure --enable-checking=release --enable-languages=c,c++ --disable-multilib
Thread model: posix
gcc version 7.3.0 (GCC) 
[root@localhost ~]# g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/aarch64-unknown-linux-gnu/7.3.0/lto-wrapper
Target: aarch64-unknown-linux-gnu
Configured with: ../configure --enable-checking=release --enable-languages=c,c++ --disable-multilib
Thread model: posix
gcc version 7.3.0 (GCC) 
[root@localhost ~]# which gcc
/usr/local/bin/gcc
[root@localhost ~]# 

설치 성공!!!
=====================================* 이전 버전 복원 방법 *======================================
(1) 현재 gcc 버전 번호 보기
$: gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/aarch64-unknown-linux-gnu/7.3.0/lto-wrapper
Target: aarch64-unknown-linux-gnu
Configured with: ../configure --enable-checking=release --enable-languages=c,c++ --disable-multilib
Thread model: posix
gcc version 7.3.0 (GCC) 

$: g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/aarch64-unknown-linux-gnu/7.3.0/lto-wrapper
Target: aarch64-unknown-linux-gnu
Configured with: ../configure --enable-checking=release --enable-languages=c,c++ --disable-multilib
Thread model: posix
gcc version 7.3.0 (GCC) 

(2) 이전 버전의 설치 패키지 보기
$:  rpm -q gcc
package gcc is not installed
$: rpm -q g++
package g++ is not installed


(3)yum 직접 설치
$:  yum install  gcc gcc-c++

하면, 만약, 만약...
rpm-q gcc와 rpm-q g++에 설치 패키지가 있으면/etc/profile 파일에 추가하기
#gcc export PATH=$PATH:/usr/bin
/usr/local/bin 디렉터리, mv gcc~와 mv g++~
실행source/etc/profile
gcc 교체 여부 확인
마지막으로 ~/디렉터리의 gcc와 g++를/usr/local/bin으로 이동

좋은 웹페이지 즐겨찾기