CentOS 7.6 編譯安裝最新版本GCC 9.2.0 實錄

? ? ? ?最近打算用ScyllaDB做分布式數據庫殿遂,但在CentOS7.6上發(fā)現GCC太老需要升級诈铛,GCC并不好編譯需要很多依賴的和對應的版本,試了兩天終于通過了墨礁,編譯過程比較漫長朋友們需要耐心等待幢竹。以下是已經驗證過可以正確編譯安裝的步驟給大家參考,歡迎指教恩静!?


root@xxx-xxxx ~ # cat /etc/redhat-release # 查看當前l(fā)inux版本信息

CentOS Linux release 7.6.1810 (Core)

root@xxx-xxxx ~ # gcc -v? ? # 查看當前gcc版本信息

使用內建 specs焕毫。

COLLECT_GCC=gcc

COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper

目標:x86_64-redhat-linux

配置為:../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,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux

線程模型:posix

gcc 版本 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC)

root@xxx-xxxx ~ # yum -y install wget bzip2 gcc gcc-c++ glibc-headers

已加載插件:fastestmirror

Loading mirror speeds from cached hostfile

base? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? | 3.6 kB? 00:00:00? ?

epel? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? | 5.3 kB? 00:00:00? ?

extras? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? | 3.4 kB? 00:00:00? ?

updates? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? | 3.4 kB? 00:00:00? ?

軟件包 wget-1.14-18.el7_6.1.x86_64 已安裝并且是最新版本

軟件包 bzip2-1.0.6-13.el7.x86_64 已安裝并且是最新版本

軟件包 gcc-4.8.5-36.el7_6.2.x86_64 已安裝并且是最新版本

軟件包 gcc-c++-4.8.5-36.el7_6.2.x86_64 已安裝并且是最新版本

軟件包 glibc-headers-2.17-260.el7_6.6.x86_64 已安裝并且是最新版本

無須任何處理

root@xxx-xxxx ~ # wget -c -P /opt/tmp/ https://mirrors.tuna.tsinghua.edu.cn/gnu/gcc/gcc-9.2.0/gcc-9.2.0.tar.gz? ? # 下載安裝源碼壓縮包

--2019-09-17 01:39:04--? https://ftp.gnu.org/gnu/gcc/gcc-9.2.0/gcc-9.2.0.tar.xz

正在解析主機 ftp.gnu.org (ftp.gnu.org)... 209.51.188.20, 2001:470:142:3::b

正在連接 ftp.gnu.org (ftp.gnu.org)|209.51.188.20|:443... 已連接。

已發(fā)出 HTTP 請求驶乾,正在等待回應... 200 OK

長度:70607648 (67M) [application/x-tar]

正在保存至: “gcc-9.2.0.tar.xz”

100%[===========================================================================>] 70,607,648? 464KB/s 用時 99s? ?

2019-09-17 01:40:44 (696 KB/s) - 已保存 “gcc-9.2.0.tar.xz” [70607648/70607648])

root@xxx-xxxx ~ # cd /opt/tmp/

root@xxx-xxxx /opt/tmp # tar -zxvf gcc-9.2.0.tar.gz? ? # 解壓縮源碼包

......

......

gcc-9.2.0/ar-lib

gcc-9.2.0/gotools/

gcc-9.2.0/gotools/Makefile.am

gcc-9.2.0/gotools/README

gcc-9.2.0/gotools/go.1

gcc-9.2.0/gotools/gofmt.1

gcc-9.2.0/gotools/Makefile.in

gcc-9.2.0/gotools/configure

gcc-9.2.0/gotools/aclocal.m4

gcc-9.2.0/gotools/configure.ac

gcc-9.2.0/gotools/ChangeLog

root@xxx-xxxx /opt/tmp/gcc-9.2.0 # cd gcc-9.2.0

root@xxx-xxxx /opt/tmp/gcc-9.2.0 # ./contrib/download_prerequisites? ? #下載gmp mpfr mpc等供編譯需求的依賴項

2019-09-17 01:43:33 URL: ftp://gcc.gnu.org/pub/gcc/infrastructure/gmp-6.1.0.tar.bz2 [2383840] -> "./gmp-6.1.0.tar.bz2" [1]

2019-09-17 01:43:39 URL: ftp://gcc.gnu.org/pub/gcc/infrastructure/mpfr-3.1.4.tar.bz2 [1279284] -> "./mpfr-3.1.4.tar.bz2" [1]

2019-09-17 01:43:43 URL: ftp://gcc.gnu.org/pub/gcc/infrastructure/mpc-1.0.3.tar.gz [669925] -> "./mpc-1.0.3.tar.gz" [1]

2019-09-17 01:43:50 URL: ftp://gcc.gnu.org/pub/gcc/infrastructure/isl-0.18.tar.bz2 [1658291] -> "./isl-0.18.tar.bz2" [1]

gmp-6.1.0.tar.bz2: 確定

mpfr-3.1.4.tar.bz2: 確定

mpc-1.0.3.tar.gz: 確定

isl-0.18.tar.bz2: 確定

All prerequisites downloaded successfully.

root@xxx-xxxx /opt/tmp/gcc-9.2.0 # mkdir build? ? #不能在source目錄下configure必須在上一層的目錄下

root@xxx-xxxx /opt/tmp/gcc-9.2.0/build # cd build

root@xxx-xxxx /opt/tmp/gcc-9.2.0/build # ../configure --prefix=/usr/local/gcc-9.2.0 --enable-bootstrap --enable-checking=release --enable-languages=c,c++ --disable-multilib

checking=release --enable-languages=c,c++ --disable-multilib

checking build system type... x86_64-pc-linux-gnu

checking host system type... x86_64-pc-linux-gnu

checking target system type... x86_64-pc-linux-gnu

checking for a BSD-compatible install... /usr/bin/install -c

checking whether ln works... yes

checking whether ln -s works... yes

checking for a sed that does not truncate output... /usr/bin/sed

checking for gawk... gawk

checking for libatomic support... yes

checking for libitm support... yes

checking for libsanitizer support... yes

checking for libvtv support... yes

checking for libhsail-rt support... yes

checking for libphobos support... yes

checking for gcc... gcc

checking whether the C compiler works... yes

checking for C compiler default output file name... a.out

checking for suffix of executables...

checking whether we are cross compiling... no

checking for suffix of object files... o

checking whether we are using the GNU C compiler... yes

checking whether gcc accepts -g... yes

checking for gcc option to accept ISO C89... none needed

checking for g++... g++

checking whether we are using the GNU C++ compiler... yes

checking whether g++ accepts -g... yes

checking whether g++ accepts -static-libstdc++ -static-libgcc... no

checking for gnatbind... no

checking for gnatmake... no

checking whether compiler driver understands Ada... no

checking how to compare bootstrapped objects... cmp --ignore-initial=16

$$

f1

$$

f2

checking for objdir... .libs

configure: WARNING: using in-tree isl, disabling version check

*** This configuration is not supported in the following subdirectories:

? ? gnattools gotools target-libada target-libhsail-rt target-libphobos target-zlib target-libbacktrace target-libgfortran target-libgo target-libffi target-libobjc target-liboffloadmic

? ? (Any other directories should still work fine.)

checking for default BUILD_CONFIG... bootstrap-debug

checking for --enable-vtable-verify... no

checking for bison... no

checking for byacc... no

checking for yacc... no

checking for bison... no

checking for gm4... no

checking for gnum4... no

checking for m4... m4

checking for flex... no

checking for lex... no

checking for flex... no

checking for makeinfo... no

/opt/tmp/gcc-9.2.0/missing: line 81: makeinfo: command not found

checking for expect... no

checking for runtest... no

checking for ar... ar

checking for as... as

checking for dlltool... no

checking for ld... ld

checking for lipo... no

checking for nm... nm

checking for ranlib... ranlib

checking for strip... strip

checking for windres... no

checking for windmc... no

checking for objcopy... objcopy

checking for objdump... objdump

checking for otool... no

checking for readelf... readelf

checking for cc... cc

checking for c++... c++

checking for gcc... gcc

checking for gfortran... no

checking for gccgo... no

checking for gdc... no

checking for ar... no

checking for ar... ar

checking for as... no

checking for as... as

checking for dlltool... no

checking for dlltool... no

checking for ld... no

checking for ld... ld

checking for lipo... no

checking for lipo... no

checking for nm... no

checking for nm... nm

checking for objcopy... no

checking for objcopy... objcopy

checking for objdump... no

checking for objdump... objdump

checking for otool... no

checking for otool... no

checking for ranlib... no

checking for ranlib... ranlib

checking for readelf... no

checking for readelf... readelf

checking for strip... no

checking for strip... strip

checking for windres... no

checking for windres... no

checking for windmc... no

checking for windmc... no

checking where to find the target ar... host tool

checking where to find the target as... host tool

checking where to find the target cc... just compiled

checking where to find the target c++... just compiled

checking where to find the target c++ for libstdc++... just compiled

checking where to find the target dlltool... host tool

checking where to find the target gcc... just compiled

checking where to find the target gfortran... host tool

checking where to find the target gccgo... host tool

checking where to find the target gdc... host tool

checking where to find the target ld... host tool

checking where to find the target lipo... host tool

checking where to find the target nm... host tool

checking where to find the target objcopy... host tool

checking where to find the target objdump... host tool

checking where to find the target otool... host tool

checking where to find the target ranlib... host tool

checking where to find the target readelf... host tool

checking where to find the target strip... host tool

checking where to find the target windres... host tool

checking where to find the target windmc... host tool

checking whether to enable maintainer-specific portions of Makefiles... no

configure: creating ./config.status

config.status: creating Makefile

root@xxx-xxxx /opt/tmp/gcc-9.2.0/build # make

......

......

make? all-recursive

make[3]: 進入目錄“/opt/tmp/gcc-9.2.0/build/x86_64-pc-linux-gnu/libitm”

Making all in testsuite

make[4]: 進入目錄“/opt/tmp/gcc-9.2.0/build/x86_64-pc-linux-gnu/libitm/testsuite”

make[4]: 對“all”無需做任何事邑飒。

make[4]: 離開目錄“/opt/tmp/gcc-9.2.0/build/x86_64-pc-linux-gnu/libitm/testsuite”

make[4]: 進入目錄“/opt/tmp/gcc-9.2.0/build/x86_64-pc-linux-gnu/libitm”

true? DO=all multi-do # make

make[4]: 離開目錄“/opt/tmp/gcc-9.2.0/build/x86_64-pc-linux-gnu/libitm”

make[3]: 離開目錄“/opt/tmp/gcc-9.2.0/build/x86_64-pc-linux-gnu/libitm”

make[2]: 離開目錄“/opt/tmp/gcc-9.2.0/build/x86_64-pc-linux-gnu/libitm”

Checking multilib configuration for libatomic...

make[2]: 進入目錄“/opt/tmp/gcc-9.2.0/build/x86_64-pc-linux-gnu/libatomic”

Makefile:867: warning: overriding recipe for target `all-multi'

Makefile:861: warning: ignoring old recipe for target `all-multi'

make? all-recursive

make[3]: 進入目錄“/opt/tmp/gcc-9.2.0/build/x86_64-pc-linux-gnu/libatomic”

Makefile:867: warning: overriding recipe for target `all-multi'

Makefile:861: warning: ignoring old recipe for target `all-multi'

Making all in testsuite

make[4]: 進入目錄“/opt/tmp/gcc-9.2.0/build/x86_64-pc-linux-gnu/libatomic/testsuite”

make[4]: 對“all”無需做任何事。

make[4]: 離開目錄“/opt/tmp/gcc-9.2.0/build/x86_64-pc-linux-gnu/libatomic/testsuite”

make[4]: 進入目錄“/opt/tmp/gcc-9.2.0/build/x86_64-pc-linux-gnu/libatomic”

Makefile:867: warning: overriding recipe for target `all-multi'

Makefile:861: warning: ignoring old recipe for target `all-multi'

true? DO=all multi-do # make

make[4]: 離開目錄“/opt/tmp/gcc-9.2.0/build/x86_64-pc-linux-gnu/libatomic”

make[3]: 離開目錄“/opt/tmp/gcc-9.2.0/build/x86_64-pc-linux-gnu/libatomic”

make[2]: 離開目錄“/opt/tmp/gcc-9.2.0/build/x86_64-pc-linux-gnu/libatomic”

make[1]: 離開目錄“/opt/tmp/gcc-9.2.0/build”

root@xxx-xxxx /opt/tmp/gcc-9.2.0/build # make install

......

......

Libraries have been installed in:

? /usr/local/gcc-9.2.0/lib/../lib64

If you ever happen to want to link against installed libraries

in a given directory, LIBDIR, you must either use libtool, and

specify the full pathname of the library, or use the `-LLIBDIR'

flag during linking and do at least one of the following:

? - add LIBDIR to the `LD_LIBRARY_PATH' environment variable

? ? during execution

? - add LIBDIR to the `LD_RUN_PATH' environment variable

? ? during linking

? - use the `-Wl,-rpath -Wl,LIBDIR' linker flag

? - have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for

more information, such as the ld(1) and ld.so(8) manual pages.

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

make[4]: 對“install-data-am”無需做任何事级乐。

make[4]: 離開目錄“/opt/tmp/gcc-9.2.0/build/x86_64-pc-linux-gnu/libatomic”

make[3]: 離開目錄“/opt/tmp/gcc-9.2.0/build/x86_64-pc-linux-gnu/libatomic”

make[2]: 離開目錄“/opt/tmp/gcc-9.2.0/build/x86_64-pc-linux-gnu/libatomic”

make[1]: 離開目錄“/opt/tmp/gcc-9.2.0/build”

root@xxx-xxxx /opt/tmp/gcc-9.2.0/build # gcc -v? ? #查看當前gcc版本

使用內建 specs疙咸。

COLLECT_GCC=gcc

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

目標:x86_64-pc-linux-gnu

配置為:../configure --prefix=/usr/local/gcc-9.2.0 --enable-bootstrap --enable-checking=release --enable-languages=c,c++ --disable-multilib

線程模型:posix

gcc 版本 9.2.0 (GCC)

root@xxx-xxxx /opt/tmp/gcc-9.2.0/build # echo -e '\nexport PATH=/usr/local/gcc-9.2.0/bin:$PATH\n' >> /etc/profile.d/gcc.sh && source /etc/profile.d/gcc.sh

root@xxx-xxxx /opt/tmp/gcc-9.2.0/build # ln -sv /usr/local/gcc-9.2.0/include/ /usr/include/gcc? ? #導出頭文件

"/usr/include/gc" -> "/usr/local/gcc-9.2.0/include/"

root@xxx-xxxx /opt/tmp/gcc-9.2.0/build # ldconfig -v? ? #配置生效

......

......

? ? libkrb5support.so.0 -> libkrb5support.so.0.1

? ? libutempter.so.0 -> libutempter.so.1.1.6

? ? libxml2.so.2 -> libxml2.so.2.9.1

? ? libmemusage.so -> libmemusage.so

? ? libstdc++.so.6 -> libstdc++.so.6.0.19

? ? libcom_err.so.2 -> libcom_err.so.2.1

? ? libgmp.so.10 -> libgmp.so.10.2.0

? ? libsqlite3.so.0 -> libsqlite3.so.0.8.6

? ? libidn.so.11 -> libidn.so.11.6.11

? ? libncursesw.so.5 -> libncursesw.so.5.9

? ? libnl-genl-3.so.200 -> libnl-genl-3.so.200.23.0

? ? libnl-xfrm-3.so.200 -> libnl-xfrm-3.so.200.23.0

? ? libply.so.2 -> libply.so.2.1.0

? ? libnuma.so.1 -> libnuma.so.1

? ? libuuid.so.1 -> libuuid.so.1.3.0

? ? libfipscheck.so.1 -> libfipscheck.so.1.2.1

? ? libsnappy.so.1 -> libsnappy.so.1.1.4

? ? libcrypt.so.1 -> libcrypt-2.17.so

? ? libhandle.so.1 -> libhandle.so.1.0.3

? ? libestr.so.0 -> libestr.so.0.0.0

? ? libudev.so.1 -> libudev.so.1.6.2

/lib/sse2: (hwcap: 0x0000000004000000)

/lib64/sse2: (hwcap: 0x0000000004000000)

/lib64/tls: (hwcap: 0x8000000000000000)

root@xxx-xxxx /opt/tmp/gcc-9.2.0/build # ldconfig -p |grep gcc? ? #導出驗證

? ? libgcc_s.so.1 (libc6,x86-64) => /lib64/libgcc_s.so.1

root@xxx-xxxx /opt/tmp/gcc-9.2.0/build # gcc -v? ? # 查看升級后的gcc版本信息,驗證安裝是否成功

使用內建 specs唇牧。

COLLECT_GCC=gcc

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

目標:x86_64-pc-linux-gnu

配置為:../configure --prefix=/usr/local/gcc --enable-bootstrap --enable-checking=release --enable-languages=c,c++ --disable-multilib

線程模型:posix

gcc 版本 9.2.0 (GCC)


注意:GCC是Linux的核心模塊罕扎,升級可能會導致一些問題,請謹慎升級丐重,升級之前做好備份工作腔召。

以上內容來自我的CSDN博客:https://blog.csdn.net/RyanFang/article/details/100927373

?著作權歸作者所有,轉載或內容合作請聯系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市扮惦,隨后出現的幾起案子臀蛛,更是在濱河造成了極大的恐慌,老刑警劉巖崖蜜,帶你破解...
    沈念sama閱讀 216,470評論 6 501
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件浊仆,死亡現場離奇詭異,居然都是意外死亡豫领,警方通過查閱死者的電腦和手機抡柿,發(fā)現死者居然都...
    沈念sama閱讀 92,393評論 3 392
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來等恐,“玉大人洲劣,你說我怎么就攤上這事】问撸” “怎么了囱稽?”我有些...
    開封第一講書人閱讀 162,577評論 0 353
  • 文/不壞的土叔 我叫張陵,是天一觀的道長二跋。 經常有香客問我战惊,道長,這世上最難降的妖魔是什么扎即? 我笑而不...
    開封第一講書人閱讀 58,176評論 1 292
  • 正文 為了忘掉前任吞获,我火速辦了婚禮况凉,結果婚禮上,老公的妹妹穿的比我還像新娘衫哥。我一直安慰自己茎刚,他們只是感情好,可當我...
    茶點故事閱讀 67,189評論 6 388
  • 文/花漫 我一把揭開白布撤逢。 她就那樣靜靜地躺著膛锭,像睡著了一般。 火紅的嫁衣襯著肌膚如雪蚊荣。 梳的紋絲不亂的頭發(fā)上初狰,一...
    開封第一講書人閱讀 51,155評論 1 299
  • 那天,我揣著相機與錄音互例,去河邊找鬼奢入。 笑死,一個胖子當著我的面吹牛媳叨,可吹牛的內容都是我干的腥光。 我是一名探鬼主播,決...
    沈念sama閱讀 40,041評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼糊秆,長吁一口氣:“原來是場噩夢啊……” “哼武福!你這毒婦竟也來了?” 一聲冷哼從身側響起痘番,我...
    開封第一講書人閱讀 38,903評論 0 274
  • 序言:老撾萬榮一對情侶失蹤捉片,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后汞舱,有當地人在樹林里發(fā)現了一具尸體伍纫,經...
    沈念sama閱讀 45,319評論 1 310
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內容為張勛視角 年9月15日...
    茶點故事閱讀 37,539評論 2 332
  • 正文 我和宋清朗相戀三年昂芜,在試婚紗的時候發(fā)現自己被綠了莹规。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 39,703評論 1 348
  • 序言:一個原本活蹦亂跳的男人離奇死亡泌神,死狀恐怖良漱,靈堂內的尸體忽然破棺而出,到底是詐尸還是另有隱情腻扇,我是刑警寧澤债热,帶...
    沈念sama閱讀 35,417評論 5 343
  • 正文 年R本政府宣布砾嫉,位于F島的核電站幼苛,受9級特大地震影響,放射性物質發(fā)生泄漏焕刮。R本人自食惡果不足惜舶沿,卻給世界環(huán)境...
    茶點故事閱讀 41,013評論 3 325
  • 文/蒙蒙 一墙杯、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧括荡,春花似錦高镐、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,664評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至邑闲,卻和暖如春算行,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背苫耸。 一陣腳步聲響...
    開封第一講書人閱讀 32,818評論 1 269
  • 我被黑心中介騙來泰國打工州邢, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人褪子。 一個月前我還...
    沈念sama閱讀 47,711評論 2 368
  • 正文 我出身青樓量淌,卻偏偏與公主長得像,于是被迫代替她去往敵國和親嫌褪。 傳聞我的和親對象是個殘疾皇子呀枢,可洞房花燭夜當晚...
    茶點故事閱讀 44,601評論 2 353

推薦閱讀更多精彩內容