Gcc 安装

gcc 的官方网址: https://gcc.gnu.org/

源码编译安装

官方安装文档地址:https://gcc.gnu.org/install/

下载源码

svn

svn co svn://gcc.gnu.org/svn/gcc/tags/tagname gcc
The SVN tag for GCC X.Y.Z is of the form gcc_X_Y_Z_release
gcc_4_9_3_release
详细信息https://gcc.gnu.org/svn.html

网址

镜像列表 :https://gcc.gnu.org/mirrors.html
看看哪个可以使用,点进去选择,release,目录下面选择
自己想要的版本,然后再点进去,选择不同的解压方式,下载源码。

要求

这个是官方给的文档 ,给出了编译gcc需要的具体需求
https://gcc.gnu.org/install/prerequisites.html
说实话,没看懂,太多了,不过不要紧,使用下面的命令就好
sudo apt-get install build-essential
该命令会安装一些必要的编译工具。

编译

根据自己下载文件格式解压gcc ,这里使用 .tar.xz

xz -d gcc.tar.xz
tar -xvf gcc.tar 
cd ~
mkdir gcc_build
cd  gcc_build
/your/gcc/path/configure 
这里我使用默认的配置,并没有修改,有需求的可以看看官方文档:https://gcc.gnu.org/install/configure.html
make bootstrap -j4 
boostrap 是一个gcc提供的选项,会把gcc编译三次,对比三次结果看看编译是否成功,-j4 ,表示使用4线程来编译,这个根据个人电脑进行设置,make特殊标记,还是官方文档吧:https://gcc.gnu.org/install/build.html
如果有时间,可以使用测试方案,测试一下,这个是可选的哈哈
https://gcc.gnu.org/install/test.html
最后就是 
make  install
需要root权限。

make boostrap

猜你喜欢

转载自blog.csdn.net/li740207611/article/details/74974068