由于某软件只支持gcc4.1的编译,而系统的gcc版本为4.4,需要装两个版本的gcc。
安装gcc前首先需要安装texinfo:
sudo yum install texinfo
由于我的OS是64位的,还需安装支持32位开发的库:
sudo yum install glibc-devel.i686 libstdc++-devel.i686
检查gcc是否支持multilib开发:
$ gcc -print-multi-lib; gcc -print-multi-os-directory; gcc -print-multi-os-directory -m32 |
下载gcc4.1.2的源码包,解压后:
./configure --prefix=/usr/local/gcc-4.1.2
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. make[3]: *** [fastjar.info] 错误 1 make[3]:正在离开目录 `/home/ssm/gcc-obj/fastjar' make[2]: *** [all] 错误 2 make[2]:正在离开目录 `/home/ssm/gcc-obj/fastjar' make[1]: *** [all-fastjar] 错误 2 make[1]:正在离开目录 `/home/ssm/gcc-obj' make: *** [all] 错误 2 |
解读错误与解决方法:
参考http://blog.youkuaiyun.com/galois_godel/article/details/6750331
(主要原因是GCC的版本过高) 1:全英文的这部分说的是你的系统中缺少相应版本的makeinfo软件。 因为gcc4.1以上的版本需要makeinfo的版本为4.2或更高。 2:本机使用的Texinfo是4.11版本, 出现此错误的原因也在于configure文件中texinfo对该版本不支持,可以在解压gcc4.1.1文件夹中的configure文件里找到 以下语句 # For an installed makeinfo, we require it to be from texinfo 4.2 or 其中4\.[2-9]|[5-9]表示的是支持4.2-4.9之间的几个版本,所以需要自己添加4\.[1-9][0-9]*,以支持4.11版本。即把'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])'后保存,编译通过。 |
sudo make install 成功之后,在/usr/bin中创建链接
sudo ln -s /usr/local/gcc-4.1.2/bin/gcc /usr/bin/gcc2
sudo ln -s /usr/local/gcc-4.1.2/bin/g++ /usr/bin/g++2
sudo ln -s /usr/local/gcc-4.1.2/bin/cpp /usr/bin/cpp2
转载于:https://blog.51cto.com/dreanter/800860