centos7 gcc升级
2024-08-23 03:58:54
1. 安装必备
yum groupinstall "Development Tools"
yum install glibc-static libstdc++-static
2. 编译安装 gcc
another place recommendated is ustc opensouce mirror https://mirrors.ustc.edu.cn/gnu/gcc/
wget http://ftp.tsukuba.wide.ad.jp/software/gcc/releases/gcc-7.3.0/gcc-7.3.0.tar.gz
tar -zxvf gcc-7.3.
cd gcc-7.3.
./contrib/download_prerequisites #安装依赖库,以前升级gcc非常麻烦,因为gcc依赖了mpfr、gmp、mpc 和isl共四个库,下载也麻烦 ,现在简单了
mkdir build
cd build
#在gcc目录,执行配置命令: ./configure --prefix=/usr/local/gcc7.3.0 --enable-multilib;
#如果只需要支持c,c++编译器,则执行配置命令:./configure --prefix=/usr/local/gcc7.3.0 --disable-multilib --enable-languages=c,c++
# –enable-checking=release 增加一些检查,也可以–disable-checking生成的编译器在编译过程中不做额外检查
#–enable-languages=c,c++ 你要让你的gcc支持的编程语言
#–disable-multilib 取消多目标库编译(取消32位库编译)
../configure --prefix=/usr/local/gcc7.3.0 --enable-checking=release --enable-languages=c,c++ --disable-multilib
make # or make -j which could determin the parallel compiling job number.
make install #here would install to the folder /usr/local/gcc7.3.0 which is specified by argument --prefix
optional step:
uninstall lower version of gcc if you has already installed in the system.
rpm -q gcc #query if gcc has installed
rpm -q gcc-c++ #query if gcc-c++ has installed
rpm -e {package name which has listed if you have gcc installed, on centos , it maybe list as follows}
#gcc-4.8.-.el7_4..x86_64
#gcc-c++-4.8.-.el7_4..x86_64
3. add gcc to the system path
vim /etc/profile
add the following content at the end of file:
export PATH=$PATH:/usr/local/gcc7.3.0/bin
or just create a soft link to /usr/bin
sudo ln -s /usr/local/gcc7.3.0/bin/gcc /usr/bin/gcc
sudo ln -s /usr/local/gcc7.3.0/bin/g++ /usr/bin/g++
4. view the gcc version
gcc --version
g++ --version
output:
4. FAQ
/lib64/libstdc++.so.6: version `GLIBCXX_3.4.21’ not found (required
solution:
find / -name libstdc++.so*
output:
/usr/lib64/libstdc++.so.6
/usr/lib64/libstdc++.so.6.0.19
/usr/lib64/libstdc++.so.6.0.24
/usr/share/gdb/auto-load/usr/lib64/libstdc++.so.6.0.19-gdb.py
/usr/share/gdb/auto-load/usr/lib64/libstdc++.so.6.0.19-gdb.pyc
/usr/share/gdb/auto-load/usr/lib64/libstdc++.so.6.0.19-gdb.pyo
/usr/local/lib64/libstdc++.so.6.0.24
/usr/local/lib64/libstdc++.so.6
/usr/local/lib64/libstdc++.so
/usr/local/lib64/libstdc++.so.6.0.24-gdb.py
找到这个这个目录下面的libstdc++.so.6.0.xx,我的是24
cp /usr/local/lib64/libstdc++.so.6.0. /usr/lib64
ldconfig #this is required
5. Alternative solution( not recommondated)
5.1 install devtoolset-6
sudo yum install centos-release-scl
sudo yum install devtoolset-
scl enable devtoolset- bash
sudo yum list devtoolset-\*
5.2. change default gcc version using command like:
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6.3
sudo update-alternatives --config gcc
if u don't want gcc 6 as your default gcc version, you can enable it just in the current terminal:
scl enable devtoolset- bash
reference:
https://www.cnblogs.com/dalanjing/p/10618575.html
最新文章
- 常用Linux命令收集
- TopCoder SRM 639 Div.2 500 AliceGameEasy --乱搞
- 【Spring】搭建最简单的Spring MVC项目
- poj1733Parity game
- SQL实现数组的功能
- JSP 客户端请求
- System.Web.Optimization找不到引用
- 错误处理php
- jquery-ui 中treegird 逐步加载
- redis maxmemory设置
- js_day14
- 基于visual Studio2013解决算法导论之002归并排序
- FZU 1686(重复覆盖)
- java.net.ConnectException connect refured
- Cocos2d-x 多分辨率支持
- [OpenGL]配置GLFW
- Maven第四篇【私有仓库、上传jar包、引用私服jar包、上传本地项目到私服】
- ASP.NET Core轻松入门之Middleware管道模型
- Jenkins结合.net平台之Web项目编译
- python面试题(一)
热门文章
- 题解 UVa11889
- Django REST framework认证权限和限制和频率
- [TypeScript ] Using the Null Coalescing operator with TypeScript 3.7
- Hive 调优
- python - 使用psutils
- Qt同步线程(QMutex QMutexLocker QReadWriteLock QSemaphore QWaitCondition )
- 洛谷 P2894 [USACO08FEB]酒店
- 机器学习实战(1)- KNN
- 如何手动安装WordPress主题和插件(Linux)
- Python里面如何生成随机数?