CentOS上GCC 升級到6.3.0的方法,centos6.3.0

來源:互聯網
上載者:User

CentOS上GCC 升級到6.3.0的方法,centos6.3.0

虛擬機器環境資訊:

[root@localhost /]# cat /etc/redhat-release

CentOS Linux release 7.3.1611 (Core)

[root@localhost /]# cat /proc/version

Linux version 3.10.0-514.el7.x86_64 (builder@kbuilder.dev.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-11) (GCC) ) #1 SMP Tue Nov 22 16:42:41 UTC 2016

可以看出gcc版本為4.8.5

GCC依賴於gmp4.2+,mpfr2.4+和mpc0.8+,這裡直接下載安裝最新的版本。

安裝gmp6.1.2

tarxvfgmp-6.1.2.tar.xz

cdgmp-6.1.2

./configure--prefix=/usr/local/gmp

make-j20&&makeinstall

(執行./configure--prefix=/usr/local/gmp時會出現錯誤configure: error: could not find a working compiler。直接yum remove gcc 卸載然後 yum install gcc 重新安裝再執行上述操作)

安裝mpfr3.1.5mpfr依賴於gmp

tarxvfmpfr-3.1.5.tar.gz

cdmpfr-3.1.5

./configure--prefix=/usr/local/mpfr--with-gmp=/usr/local/gmp

make-j20&&makeinstall

安裝mpc1.0.3mpc依賴於gmp和mpfr

tarxvfmpc-1.0.3.tar.gz

cdmpc-1.0.3

./configure--prefix=/usr/local/mpc--with-gmp=/usr/local/gmp-with-mpfr=/usr/local/mpfr

make-j20&&makeinstall

安裝GCC6.3.0

tarxvfgcc-6.3.0.tar.gz

cdgcc-6.3.0

./configure--prefix=/usr/local/gcc--enable-threads=posix--disable-checking--disable-multilib--enable-languages=c,c++--with-gmp=/usr/local/gmp--with-mpfr=/usr/local/mpfr--with-mpc=/usr/local/mpc

make-j20&&makeinstall

安裝過程中可能會出現:

“checkingforsuffixofobjectfiles...configure:error:cannotcomputesuffixofobjectfiles:cannotcompile

See`config.log'formoredetails.

make[2]:***[configure-stage1-target-libgcc]Error1

make[2]:Leavingdirectory`/tmp/gcc-6.3.0'

make[1]:***[stage1-bubble]Error2

make[1]:Leavingdirectory`/tmp/gcc-6.3.0'

make:***[bootstrap]Error2

解決方案:

yuminstallm4

yuminstallgcc-c++

實際解決辦法:編輯變數,把我們安裝的gmp,mpfr,mpc加進去

vi/etc/ld.so.conf

添加部分:

/usr/local/lib#這個是預設系統的變數

/usr/local/gmp/lib

/usr/local/mpfr/lib

/usr/local/mpc/lib

添加儲存後記得更新動態庫的緩衝:

ldconfig-v

更新後再去重新編譯安裝。

備份系統預設的gcc版本

mv/usr/bin/gcc/usr/bin/gcc-bak

mv/usr/bin/g++/usr/bin/g++-bak

mv/usr/bin/c++/usr/bin/c++-bak

建立新的gcc軟串連

ln-sf/usr/local/gcc/bin/gcc/usr/bin/gcc

ln-sf/usr/local/gcc/bin/c++/usr/bin/c++

ln-sf/usr/local/gcc/bin/g++/usr/bin/g++

ln-sf/usr/local/gcc/lib64/libstdc++.so.6.0.22/usr/lib64/libstdc++.so.6

查看gcc版本:

[root@localhost ~]# gcc --version

gcc (GCC) 6.3.0

Copyright (C) 2016 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@localhost ~]# gcc -v

Using built-in specs.

COLLECT_GCC=gcc

COLLECT_LTO_WRAPPER=/usr/local/gcc/libexec/gcc/x86_64-pc-linux-gnu/6.3.0/lto-wrapper

Target: x86_64-pc-linux-gnu

Configured with: ./configure --prefix=/usr/local/gcc --enable-threads=posix --disable-checking --disable-multilib --enable-languages=c,c++ --with-gmp=/usr/local/gmp --with-mpfr=/usr/local/mpfr --with-mpc=/usr/local/mpc

Thread model: posix

gcc version 6.3.0 (GCC)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.