当前位置: 代码迷 >> 综合 >> 黑猴子的家:Centos 7.x gcc 4.8.5 升级到 gcc 4.9.4
  详细解决方案

黑猴子的家:Centos 7.x gcc 4.8.5 升级到 gcc 4.9.4

热度:126   发布时间:2023-09-14 20:59:49.0

一、gcc 安装方式一

1、查看当前版本

[root@hadoop102 software]# gcc -v
4.8.5

2、下载 gcc-4.9.0.tar.bz2

[root@hadoop102 software]# wget http://ftp.gnu.org/gnu/gcc/gcc-4.9.0/gcc-4.9.0.tar.bz2

3、解压

[root@hadoop102 software]# tar -jxvf gcc-4.9.0.tar.bz2

4、进入gcc-4.9.0目录

[root@hadoop102 software]# cd gcc-4.9.0

5、contrib

[root@hadoop102 gcc-4.9.0]# ./contrib/download_prerequisites

6、创建build目录

[root@hadoop102 gcc-4.9.0]# mkdir build

7、进入build目录

[root@hadoop102 software]# cd build

8、configure

[root@hadoop102 build]# pwd
/opt/software/gcc-4.9.0/build
[root@hadoop102 build]# ../configure --enable-checking=release --enable-languages=c,c++ --disable-multilib

9、make -j4

[root@hadoop102 software]# make -j4

10、make install

[root@hadoop102 software]# make install

11、gcc -v

[root@hadoop102 software]# gcc -v

12、Error

Libraries have been installed in:/usr/local/lib/../lib64If 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 variableduring execution- add LIBDIR to the `LD_RUN_PATH' environment variableduring linking- use the `-Wl,-rpath -Wl,LIBDIR' linker flag- have your system administrator add LIBDIR to `/etc/ld.so.conf'

这是告诉你接下来要怎么用。简单的办法是在 /etc/ld.so.conf.d 下新建一个文件 local.conf,里边写上 /usr/local/lib。然后以 root 权限执行 ldconfig。这样你的系统才会找得到安装到 /usr/local/lib 下的库文件。

13、解决Error

[root@hadoop102 build]# cd /etc/ld.so.conf.d/
[root@hadoop102 ld.so.conf.d]# touch local.conf
[root@hadoop102 ld.so.conf.d]# echo '/usr/local/lib' > local.conf 
[root@hadoop102 ld.so.conf.d]# ldconfig

14、make install

[root@hadoop102 software]# make install

15、gcc -v

[root@hadoop102 software]# gcc -v

二、gcc 安装方式二(推荐)

1、安装依赖

[root@hadoop102 software]# yum install -y m4

2、gmp安装

[root@hadoop102 software]# wget http://ftp.gnu.org/gnu/gmp/gmp-5.0.1.tar.gz
[root@hadoop102 software]# tar -xvzf gmp-5.0.1.tar.gz
[root@hadoop102 software]# cd gmp-5.0.1/ && mkdir build && cd build/
[root@hadoop102 build]# ../configure --prefix=/usr/local/gmp-5.0.1
[root@hadoop102 build]# make -j4 && make install

3、mpfr安装

[root@hadoop102 software]# wget http://ftp.gnu.org/gnu/mpfr/mpfr-3.1.5.tar.gz
[root@hadoop102 software]# tar -xvzf mpfr-3.1.5.tar.gz
[root@hadoop102 software]# cd mpfr-3.1.5/ && mkdir build && cd build/
[root@hadoop102 build]# ../configure --prefix=/usr/local/mpfr-3.1.5 --with-gmp=/usr/local/gmp-5.0.1
[root@hadoop102 build]# make -j4 && make install

4、mpc安装

[root@hadoop102 software]# wget http://ftp.gnu.org/gnu/mpc/mpc-1.0.3.tar.gz
[root@hadoop102 software]# tar -xvzf mpc-1.0.3.tar.gz
[root@hadoop102 software]# cd mpc-1.0.3/ && mkdir build && cd build/
[root@hadoop102 build]# ../configure --prefix=/usr/local/mpc-1.0.3 --with-gmp=/usr/local/gmp-5.0.1 --with-mpfr=/usr/local/mpfr-3.1.5
[root@hadoop102 build]# make -j4 && make install

5、gcc-4.9.4 安装

[root@hadoop102 software]# wget http://mirrors.concertpass.com/gcc/releases/gcc-4.9.4/gcc-4.9.4.tar.gz
[root@hadoop102 software]# tar -jxvf gcc-4.9.4.tar.gz
[root@hadoop102 software]# cd gcc-4.9.4/ && mkdir build && cd build/
[root@hadoop102 build]# ../configure --disable-multilib --enable-languages=c,c++ --with-gmp=/usr/local/gmp-5.0.1 --with-mpfr=/usr/local/mpfr-3.1.5 --with-mpc=/usr/local/mpc-1.0.3
[root@hadoop102 build]# make -j4 && make install

6、Error

Libraries have been installed in:/usr/local/lib/../lib64If 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 variableduring execution- add LIBDIR to the `LD_RUN_PATH' environment variableduring linking- use the `-Wl,-rpath -Wl,LIBDIR' linker flag- have your system administrator add LIBDIR to `/etc/ld.so.conf'

这是告诉你接下来要怎么用。简单的办法是在 /etc/ld.so.conf.d 下新建一个文件 local.conf,里边写上 /usr/local/lib。然后以 root 权限执行 ldconfig。这样你的系统才会找得到安装到 /usr/local/lib 下的库文件。

7、解决Error

[root@hadoop102 build]# cd /etc/ld.so.conf.d/
[root@hadoop102 ld.so.conf.d]# touch local.conf
[root@hadoop102 ld.so.conf.d]# echo '/usr/local/lib' > local.conf 
[root@hadoop102 ld.so.conf.d]# ldconfig

8、make install

[root@hadoop102 software]# make install

9、gcc -v

[root@hadoop102 software]# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-unknown-linux-gnu/4.9.4/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../configure --disable-multilib --enable-languages=c,c++ --with-gmp=/usr/local/gmp-5.0.1 --with-mpfr=/usr/local/mpfr-3.1.5 --with-mpc=/usr/local/mpc-1.0.3
Thread model: posix
gcc version 4.9.4 (GCC)
  相关解决方案