make的时候报如下错
遇到该问题主要是因为系统的gcc版本不够高,默认版本应该是4.4.7
升级步骤
下载安装包
http://ftp.gnu.org/gnu/gcc/gcc-4.8.2/gcc-4.8.2.tar.bz2
解压
tar -jxvf gcc-4.8.2.tar.bz2
下载供编译需求的依赖项
这个神奇的脚本文件会帮我们下载、配置、安装依赖库,可以节约我们大量的时间和精力。
cd gcc-4.8.2
./contrib/download_prerequisites
建立一个文件夹
mkdir gcc-build-4.8.2
cd gcc-build-4.8.2
生成Makefile文件
../configure -enable-checking=release -enable-languages=c,c++ -disable-multilib
编译安装
make && make install
如果报
configure: error: C++ compiler missing or inoperational
则安装下gcc-c++依赖
yum install gcc-c++
再次查看gcc版本
如果安装完成之后还是报之前的问题,这时候可能是安装的gcc没有更新到正式环境变量和路径,按如下操作执行:
#查找gcc相关执行文件
[root@gs-server-7697 redis-6.0.1]# find / -name gcc
/usr/service/gcc-4.8.2/gcc
/usr/service/gcc-4.8.2/gcc/testsuite/ada/acats/tests/gcc
/usr/service/gcc-4.8.2/gcc-build/gcc
/usr/service/gcc-4.8.2/host-x86_64-unknown-linux-gnu/gcc
/usr/service/gcc-4.8.2/host-x86_64-unknown-linux-gnu/host-x86_64-unknown-linux-gnu/gcc
/usr/libexec/gcc
/usr/local/otp_src_19.3/erts/include/internal/gcc
/usr/local/erlang/lib/erlang/erts-8.3/include/internal/gcc
/usr/local/libexec/gcc
/usr/local/bin/gcc
/usr/local/lib/gcc
/usr/bin/gcc
/usr/lib/gcc
You have new mail in /var/spool/mail/root
[root@gs-server-7697 redis-6.0.1]# /usr/bin/gcc -v
Using built-in specs.
Target: x86_64-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-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-ppl --with-cloog --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.4.7 20120313 (Red Hat 4.4.7-23) (GCC)
[root@gs-server-7697 redis-6.0.1]# /usr/local/bin/gcc -v
Using built-in specs.
COLLECT_GCC=/usr/local/bin/gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-unknown-linux-gnu/4.8.2/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ./configure -enable-checking=release -enable-languages=c,c++ -disable-multilib
Thread model: posix
gcc version 4.8.2 (GCC)
可以看到,有多个版本的gcc存在,调整/usr/bin/gcc指向新版本gcc
mv /usr/bin/gcc /usr/bin/gcc-4.4.7
ln -s /usr/local/bin/gcc /usr/bin/gc
/usr/bin/gcc -v
可以看到,现在/usr/bin/gcc已经是新版gcc了,接着讲g++等也指向新版:
mv /usr/bin/g++ /usr/bin/g++-4.4.7
ln -s /usr/local/bin/g++ /usr/bin/g++
mv /usr/bin/c++ /usr/bin/c++-4.4.7
ln -s /usr/local/bin/c++ /usr/bin/c++
参考文章 https://www.cnblogs.com/kumufengchun/p/10192324.html
https://blog.csdn.net/LeoHan163/article/details/106074497/