在centos 64下面安装gcc 4.1.2

来源:互联网 发布:vue数据交互 编辑:程序博客网 时间:2024/06/06 03:12
  因为编译的机器装了centos 6.5,上面的gcc比较新是4.7,而外面运行的机器试centos5.6,所以编译的程序放到上面跑了之后就会出现 /lib64/libc.so.6: version `GLIBC_2.8' not found等错误(就是libc的版本太低,不支持2.8,我们可以用命令 strings /lib64/libc.so.6 | grep GLIBC_来看库支持的版本)。 所以打算在编译的机器上重新装一个4.1.2的gcc。


        安装的基本步骤没什么好说的,就是下载源码 ——》configure ——》 make ——》make install。但是过程却没这么顺利,中间出现了很多问题。

1)configure 没有错误,但make的时候出现 错误

WARNING: `makeinfo' is missing on your system.  You should only need it if
         you modified a `.texi' or `.texinfo' file, or any other file
         indirectly affecting the aspect of the manual.  The spurious
         call might also be the consequence of using a buggy `make' (AIX,
         DU, IRIX).  You might want to install the `Texinfo' package or
         the `GNU make' package.  Grab either from any GNU archive site.

a. 到网上搜索了一下,大部分的解决方案都是说 

configure文件中texinfo对该版本不支持,可以在解压gcc4.1.2文件夹中的configure文件里找到
以下语句
# For an installed makeinfo, we require it to be from texinfo 4.2 or
# higher, else we use the "missing" dummy.
if ${MAKEINFO} --version \
| egrep 'texinfo[^0-9]*([1-3][0-9]|4\.[2-9]|[5-9])' >/dev/null 2>&1; then
:
else
MAKEINFO="$MISSING makeinfo"
fi
;;
其中4\.[2-9]|[5-9]表示的是支持4.2-4.9之间的几个版本,所以需要自己添加4\.[1-9][0-9]*,以支持4.1版本。即把'texinfo[^0-9]*([1-3][0-9]|4\.[2-9]|[5-9])'编辑成'texinfo[^0-9]*([1-3][0-9]|4\.[2-9]|4\.[1-9][0-9]*|[5-9])'后保存,编译通过。

但尝试之后失败


b. 输入命令 makeinfo --version 提示说是没有命令,那么应该是没有这个库,所以下载安装这个库 texinfo 4.7。但在make的时候说是 undefined references to `tputs',然后又查了一下要 先装 ncurses-5.6,于是又下载了安装,这次make texinfo的时候果然OK了。


c. 继续回来安装 gcc,上次的错误这次终于没有了,但又出现一个新才错误 gnu/stubs-32.h: No such file or directory。继续google,重新configure,并增加选项:

./configure --enable-languages=c,c++ --disable-multilib

make j 8

make install

这次成功了。

--enable-languages=c,c++, 表示只要c,c++的gcc,不然什么语言都支持,编译会很耗时
如果不添加--disable-multilib, 那么会出现stub-32.h找不到的错误
而 -j 8使用8个线程来并行编译


0 0
原创粉丝点击