GCC/G++如何安装到本地

首先,gcc和g++是一起安装的。

1. 去gcc官网下载源代码 https://gcc.gnu.org

2.下载依赖包:进入到解压后的gcc目录,执行:./contrib/download_prerequisites

依赖包即会自动下载安装

3.编译安装:

mkdir gcc-build-4.8.5

cd gcc-build-4.8.5

../configure --prefix=/usr

make && make install

安装完成后,需要设置的相关路径如下:

export PATH="/home/zhengs/local/gcc-4.9.4/bin:$PATH"

export LD_LIBRARY_PATH="/home/zhengs/local/gcc-4.9.4/lib:/home/zhengs/local/gcc-4.9.4/lib64:$LD_LIBRARY_PATH"

export LD_RUN_PATH="/home/zhengs/local/gcc-4.9.4/lib:/home/zhengs/local/gcc-4.9.4/lib64:$LD_RUN_PATH"

export C_INCLUDE_PATH="/home/zhengs/local/gcc-4.9.4/include:$C_INCLUDE_PATH"

export CPLUS_INCLUDE_PATH="/home/zhengs/local/gcc-4.9.4/include:$CPLUS_INCLUDE_PATH"

你可能感兴趣的:(GCC/G++如何安装到本地)