centos 源码编译安装gcc 4.7.0

news/2024/7/10 5:27:36 标签: gcc, centos, library, path, fortran, build

官方参考:

http://gcc.gnu.org/wiki/InstallingGCC


GCC tends to have problems when configured in the same directory as the GCC source code, or in any subdirectory therein, as stated in the Configuration page in the install documentation.

What should be done is to untar the GCC source code, then in the source directory run ./contrib/download_prerequisites (which will download and untar MPFR, MPC and GMP in the same GCC source code directory as per the prerequisites documentation.)

Then make a peer gcc-build directory next to the GCC source code directory.

Then run the configure either by fully qualified path or by relative path while in the the gcc-build current working directory.

A makefile will be created in the gcc-build directory. Run make in the gcc-build current working directory to begin the build of GCC.

(If building a cross-compiler, there are several more prerequisite steps involved.)

The above steps are atypical of most GNU packages. GCC builds in multiple passes; which, if done within the GCC source code directory, befouls the source code directory itself. Hence the need to build in a separate build directory.

MPFR, MPC and GMP are used by GCC itself, internally. GCC does not use those facilities in the code compiled by GCC.


转载的下文有大量错误,不要尝试。

gcc官方网站 下载最新版本的gcc-4.7.0.tar.bz2
同时在infrastructure目录下寻找下载【必须】的cloog-0.16.2.tar.gz、mpc-0.8.1.tar.gz、mpfr-2.4.2.tar.bz2、ppl-0.11.tar.gz,去http://gmplib.org/ 下载最新的gmp-5.0.4.tar.bz2
开始前的注意事项:
【我是在CentOS 5.3 x64的虚拟机环境下实践的此文,推荐内存要大于2G,否则在编译一些模块时会出现因为物理内存耗光而死机的情况】

开始安装gcc 4.7.0,以下包的安装步骤不能错乱

? View Code TEXT
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
tar jxvf gmp-5.0.4.tar.bz2
cd gmp-5.0.4
./configure --prefix=/usr/local/gmp-5.0.4
make && make install
cd ../
 
tar jxvf mpfr-2.4.2.tar.bz2
cd mpfr-2.4.2
./configure --prefix=/usr/local/mpfr-2.4.2 --with-gmp=/usr/local/gmp-5.0.4
make && make install
cd ../
 
tar zxvf mpc-0.8.1.tar.gz
cd mpc-0.8.1
./configure --prefix=/usr/local/mpc-0.8.1  --with-gmp=/usr/local/gmp-5.0.4 --with-mpfr=/usr/local/mpfr-2.4.2
make && make install
cd ../

由于cloog-0.16.2是【isl-based version】,在gcc的./configure 时,使用–enable-cloog-backend=isl参数来指定cloog的后端为isl即可

? View Code TEXT
1
2
3
4
5
6
7
8
9
10
11
tar zxvf ppl-0.11.tar.gz
cd ppl-0.11
./configure --prefix=/usr/local/pp1-0.11 --with-gmp=/usr/local/gmp-5.0.4
make && make install
cd ../
 
tar zxvf cloog-0.16.2.tar.gz
cd cloog-0.16.2
./configure --prefix=/usr/local/cloog-0.16.2 --with-gmp=/usr/local/gmp-5.0.4
make && make install
cd ../

安装gcc 4.7.0,此处的参数,只针对C、C++语言,如果需要其能编译出其他工具链(如all, ada, fortran, go, java, objc, obj-c++之类的),在enable-language后面添加上,然后添加上相应的参数就是

? View Code TEXT
1
2
3
4
tar jxvf gcc-4.7.0.tar.bz2
cd gcc-4.7.0
./configure --with-gmp=/usr/local/gmp-5.0.4 --with-mpfr=/usr/local/mpfr-2.4.2 --with-mpc=/usr/local/mpc-0.8.1 --enable-languages=c,c++ --enable-threads=posix --enable-__cxa_atexit --with-cpu=generic --disable-multilib --with-ppl=/usr/local/pp1-0.11 --with-cloog=/usr/local/cloog-0.16.2 --enable-cloog-backend=isl
make && make install

将以上四个库加入系统库路径,使用在/etc/ld.so.conf中添加或LD_LIBRARY_PATH环境变量中添加的方式
如在~/.bashrc中添加上下面语句

? View Code TEXT
1
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/gmp-5.0.4/lib:/usr/local/mpfr-2.4.2/lib:/usr/local/mpc-0.8.1/lib:/usr/local/cloog-0.16.2/lib:/usr/local/ppl-0.11/lib
使用gcc -v即可查看到新安装的gcc版本已经变为4.7.0了

http://www.niftyadmin.cn/n/1858807.html

相关文章

《苏菲的世界》读书笔记

[我的github博客文章地址](http://liu946.github.io/book/2015/08/20/world-of-sufei.html) 虽然在时间上支离破碎的但总算是,看完了这本书了。给我的感觉也是比较复杂,哲学相关的我也不想说了,之后我可能会在以下阅读时摘录的一些句子下面写…

graphlab试用笔记

1.编译问题 mpi1.6会有hang up 的情况。 使用 1.4.5 https://bbs.archlinux.org/viewtopic.php?id145518 gcc 必须大于 4.2 2.sample运行问题 bool line_parser #include <graphlab.hpp> #include <iostream>using namespace std;struct web_page {std::st…

CSS实现绝对底部一个完美解决方案

CSS的简单在于它易学&#xff0c;CSS的困难在于寻找更好的解决方案。在CSS的世界里&#xff0c;似乎没有完美这种说法。所以&#xff0c;现在介绍的CSS绝对底部&#xff0c;只是目前个人见过的方案中比较完美的吧。 先说我们为什么会使用到这个CSS底部布局解决方案: 当做一个页…

apk的反编译、修改

这里有篇文章&#xff1a; apk的反编译、汉化、修改&#xff0c;实现sd2flash&#xff0c;修改smali文件 关于smali的语法&#xff1a; dalvik官方文档&#xff1a; http://source.android.com/tech/dalvik/dalvik-bytecode.html 其他&#xff1a; http://pallergabor.…

3.1HTML网页之iframe框架

3.1HTML网页之iframe框架 描述&#xff1a;iframe框架 需求&#xff1a;在一个HTML网页中&#xff0c;编写若干个超链接&#xff0c;在点击超链接时&#xff0c;打开的方式&#xff1a; 在本网页的局部打开&#xff0c;而不是在新的网页中打开&#xff01; QQ邮箱案例 技术&a…

加拿大自动垃圾分类助手走进校园【智能行业快讯 2019.7.26】

By 超神经AI 无处不在的时代&#xff0c;每天都有新的技术与研究成果出现。无论学术界还是商界&#xff0c;技术还是产品&#xff0c;AI 的进展都源源不断&#xff0c;在带给我们全新视角的同时&#xff0c;也触及我们更深的思考。HyperAI 超神经精心整理了 AI 行业的近期资讯&…

ffmpeg 0.10.3 h264_mp4toannexb 异常

在使用 ffmpeg -i test.mp4 -ss 0 -t 10 -acodec copy -vcodec copy -vbsf h264_mp4toannexb -y test.ts 命令的时候&#xff0c; 部分视频会出现异常&#xff1a; Failed to open bitstream filter h264_mp4toannexb for stream 0 with codec copy: Invalid argument Faile…

3.2HTML网页之frameset框架

3.2HTML网页之frameset框架 描述&#xff1a;网页局部刷新之frameset框架 需求&#xff1a;模拟QQ邮箱网页&#xff0c;把整个网页分割成若干个小网页(例如 top.html,left.html,right.html)&#xff0c; 然后点击left.html中的超链接&#xff0c;把内容跳转到right.html指定fr…