# CentOS 6.8 升级 GCC 和 Python #作者:老农民 #QQ: 46715422 #Email: flyingercn@wo.cn #微信: ericliu_77
# 安装gcc和python编译需要的依赖包 yum -y install glibc-devel.i686 glibc-devel ncurses ncurses-devel zlib-devel bzip2-devel openssl-devel readline-devel sqlite-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
# 编译安装GCC6.2 tar xf gcc-6.2.0.tar.bz2 cd gcc-6.2.0/ ./contrib/download_prerequisites # 为了存放编译期间产生的中间文件,我们建立一个文件夹存放这些文件 mkdir gcc-build-6.2.0 cd gcc-build-6.2.0 ../configure --prefix=/usr/local/gcc6 --enable-checking=release --enable-languages=c,c++ --enable-threads=posix --disable-multilib --disable-libunwind-exceptions --enable-bootstrap --with-system-zlib --with-arch=i686 --build=i686-redhat-linux make -j8 make install cd ../../ rm -fr gcc-6.2.0.tar.bz2 rm -fr gcc-6.2.0 gcc --version gcc (GCC) 6.2.0 Copyright © 2016 Free Software Foundation,Inc. 本程序是自由软件;请参看源代码的版权声明。本软件没有任何担保; 包括没有适销性和某一专用目的下的适用性担保。
# 编译安装Python 2.7.12 # 使用最新安装的GCC6.2编译安装,不用系统自带的gcc4 wget https://www.python.org/ftp/python/2.7.12/Python-2.7.12.tgz tar xf Python-2.7.12.tgz cd Python-2.7.12/ export LD_LIBRARY_PATH=/usr/local/lib:/usr/local/gcc6/lib:/usr/local/python27/lib:/lib:/usr/lib:/lib64:/usr/lib64:/usr/local/lib64:$LD_LIBRARY_PATH export PATH=/usr/local/bin:/usr/local/gcc6/bin:/usr/local/python27/bin:$PATH:. CC="/usr/local/gcc6/bin/gcc" ./configure --prefix=/usr/local/python27 --enable-shared CC="/usr/local/gcc6/bin/gcc" make -j `grep processor /proc/cpuinfo | wc -l` CC="/usr/local/gcc6/bin/gcc" make install cd ../ rm -fr Python-2.7.12.tgz rm -fr Python-2.7.12
# 创建环境变量文件,如果需要使用最新的GCC和Python2.7,就执行以下文件 vi ~/env.sh alias cc=/usr/local/gcc6/bin/gcc alias gcc=/usr/local/gcc6/bin/gcc alias c++=/usr/local/gcc6/bin/c++ alias g++=/usr/local/gcc6/bin/g++ alias cpp=/usr/local/gcc6/bin/cpp export LD_LIBRARY_PATH=/usr/local/lib:/usr/local/gcc6/lib:/usr/local/python27/lib:/lib:/usr/lib:/lib64:/usr/lib64:/usr/local/lib64:$LD_LIBRARY_PATH export PATH=/usr/local/bin:/usr/local/gcc6/bin:/usr/local/python27/bin:$PATH:. # 每次进系统后执行以下命令即可使用最新的GCC和Python2.7 . ~/env.sh
要买正宗新疆特产,微信扫下面二维码,加老农民咨询购买:
原文链接:https://www.f2er.com/centos/379698.html