gcc-8.4.0 软件安装教程-以昆山中心为例

1. 安装编译

(1)下载 gcc-8.4.0.tar.gz 安装包,并将其拷贝至目录 /public/home/username/sourcecode 下。

(2)在 /public/home/username/sourcecode 目录下执行命令:

tar –zxvf gcc-8.4.0.tar.gz  #解压

(3)进入解压目录 /public/home/username/sourcecode/gcc-8.4.0,创建编译目录:/public/home/username/sourcecode/gcc-8.4.0/build

(4)下载安装gcc所需的库。在目录 /public/home/username/sourcecode/gcc-8.4.0 下执行命令:

./contrib/download_prerequisites

(5)配置编译环境。在目录 /public/home/username/sourcecode/gcc-8.4.0/build 下执行命令:

module purge  #将系统默认环境变量去掉

../configure --prefix=/public/home/username/soft/gcc-8.4.0 \
--enable-languages=c,c++,fortran \
--enable-threads=posix \
--enable-shared \
--disable-checking \
--disable-multilib \
--with-system-zlib \
--with-arch_32=i686

(6)在目录 /public/home/username/sourcecode/gcc-8.4.0/build 下进行编译:

make -j 20  #20核进行编译

(7)在目录 /public/home/username/sourcecode/gcc-8.4.0/build 下进行安装:

make install

2. 配置环境

(1)更新环境变量:

vi ~/.bashrc
export PATH=/public/home/username/soft/gcc-8.4.0/bin:$PATH
export C_INCLUDE_PATH=/public/home/username/soft/gcc-8.4.0/include:$C_INCLUDE_PATH
export CPLUS_INCLUDE_PATH=/public/home/username/soft/gcc-8.4.0/include:$CPLUS_INCLUDE_PATH
export LD_LIBRARY_PATH=/public/home/username/soft/gcc-8.4.0/lib64:$LD_LIBRARY_PATH
export LIBRARY_PATH=/public/home/username/soft/gcc-8.4.0/lib:$LIBRARY_PATH
source ~/.bashrc   #刷新环境变量

(2)确认路径加载成功,执行命令:

which gcc

出现gcc路径: ~/soft/gcc-8.4.0/bin/gcc。

results matching ""

    No results matching ""