日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > linux >内容正文

linux

linux 7.4安装gcc,在 Centos 7.4 上安装Gcc 7.3

發布時間:2023/12/8 linux 23 豆豆
生活随笔 收集整理的這篇文章主要介紹了 linux 7.4安装gcc,在 Centos 7.4 上安装Gcc 7.3 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

依舊是那個老生常談的問題,Cent OS上的軟件包大都很老,比如常用的Gcc,在最新的Cent OS 7.4上,gcc的版本才到4.8.5,雖說一味追求新版并無大用,但是有些特性老版本不支持啊,很坑的有木有。

下面記錄一下安裝過程。

描述

系統為Cent OS7.4,全新安裝,更新全部軟件至最新版。

安裝準備1

2yum update -y

yum install gcc gcc-c++ gcc-gnat zlib-devel glibc-devel glibc-devel.i686 libgcc libgcc.i686 -y

安裝 glibc-devel.i686 是為了安裝32位的頭文件和庫,否則在配置的時候就會出現下面的錯誤

1configure: error: I suspect your system does not have 32-bit developement libraries (libc and headers). If you have them, rerun configure with --enable-multilib. If you do not have them, and want to build a 64-bit-only compiler, rerun configure with --disable-multilib.

網絡上清一色的叫你加入參數--disable-multilib,然而,這樣的話就少了32位的支持了。

動手1

2

3

4

5

6

7wget https://mirrors.tuna.tsinghua.edu.cn/gnu/gcc/gcc-7.3.0/gcc-7.3.0.tar.gz

tar -zxf gcc-7.3.0.tar.gz

cd gcc-7.3.0

./contrib/download_prerequisites

mkdir builddir && cd builddir

../configure

make && sudo make install

編譯過程長達數個小時,具體要多長時間得看RP了,可以用tmux把它放在后臺。

需要配置的地方非常少,安裝過程也沒什么特殊的,但是以前安裝gcc的時候隨便報個錯就一臉懵逼,需要注意的是在./contrib/download_prerequisites之后,會有執行成功的提示,log如下

1

2

3

4

5

6

7

8

92018-04-16 16:37:22 URL: ftp://gcc.gnu.org/pub/gcc/infrastructure/gmp-6.1.0.tar.bz2 [2383840] -> "./gmp-6.1.0.tar.bz2" [1]

2018-04-16 16:37:28 URL: ftp://gcc.gnu.org/pub/gcc/infrastructure/mpfr-3.1.4.tar.bz2 [1279284] -> "./mpfr-3.1.4.tar.bz2" [1]

2018-04-16 16:37:33 URL: ftp://gcc.gnu.org/pub/gcc/infrastructure/mpc-1.0.3.tar.gz [669925] -> "./mpc-1.0.3.tar.gz" [1]

2018-04-16 16:37:39 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.

這個步驟是有可能因為網絡原因出問題的,這個步驟可以把安裝gcc需要的四個依賴包弄好,網絡上的某些教程是讓你手動安裝依賴,比如這個https://www.cnblogs.com/freeweb/p/5990860.html,操作越多越容易出錯。

另外,配置同樣是需要考慮的地方,大多數時候直接執行./configure就過去了,我用了下面的配置參數

1../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++,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux

選擇這個參數并沒有什么非常實在的原因,里面很多參數我并不清楚是干嘛的,使用這個參數純粹是因為Cent OS用yum安裝的gcc的配置參數是這個。

安裝gdb

在某些情況下,升級了gcc是需要同步升級gdb的,雖然不清楚是否有具體的版本對應關系,但是傻fufu的安裝最新版就是了

1

2

3

4

5

6wget https://mirrors.tuna.tsinghua.edu.cn/gnu/gdb/gdb-8.1.tar.gz

tar -zxf gdb-8.1.tar.gz

cd gdb-8.1

mkdir builddir && cd builddir

../configure

make && make install

碎碎念

有可能在執行make install的時候報錯(內心PS,都已經編譯好了,你給我在安裝的時候報錯(ノ`Д)ノ)報錯信息如下:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20WARNING: 'makeinfo' is missing on your system.

You should only need it if you modified a '.texi' file, or

any other file indirectly affecting the aspect of the manual.

You might want to install the Texinfo package:

The spurious makeinfo call might also be the consequence of

using a buggy 'make' (AIX, DU, IRIX), in which case you might

want to install GNU make:

make[5]: *** [gdb.info] Error 127

make[5]: Leaving directory `/root/gdb-8.1/build/gdb/doc'

make[4]: *** [subdir_do] Error 1

make[4]: Leaving directory `/root/gdb-8.1/build/gdb'

make[3]: *** [install-only] Error 2

make[3]: Leaving directory `/root/gdb-8.1/build/gdb'

make[2]: *** [install] Error 2

make[2]: Leaving directory `/root/gdb-8.1/build/gdb'

make[1]: *** [install-gdb] Error 2

make[1]: Leaving directory `/root/gdb-8.1/build'

make: *** [install] Error 2

需要yum install texinfo,然后再執行make install。

至于原本安裝好的gcc的話,應該是沒了吧,我是找不到它了。

安裝軟件的推薦性是這樣的官方源>知名第三方源>手動編譯>不知名第三方源,很多時候,手動編譯需要自己安裝依賴,很多時候,自己安裝依賴還會需要安裝依賴的依賴,某些極端情況下,還會遇到依賴循環,令人十分的窒息。

自行編譯安裝并不是很推薦的操作,并且很多時候新版并不一定就更好,Cent OS一直用著老版本的軟件并不是沒有道理的。

建立builddir的目的,只是為了讓編譯產生的文件集中在一個地方,免得主目錄一大堆文件看起來不方便。

Ubuntu/Debia的軟件版本一般都比較新,不值得花大量時間手動編譯。

總結

以上是生活随笔為你收集整理的linux 7.4安装gcc,在 Centos 7.4 上安装Gcc 7.3的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。