红联Linux门户
Linux帮助

Fedora11下安装gcc-4.1.1

发布时间:2009-09-22 23:38:27来源:红联作者:iamxzg
[i=s] 本帖最后由 iamxzg 于 2009-9-25 20:16 编辑 [/i]

由于某种需要,需要把Fedora11 gcc的版本降到4.1.1,使用yum install gcc只会更新现有版本,不降反升了,那么只能通过其它途径进行安装,其过程如下:
1、先下载gcc-4.1.1.tar.bz2文件于/tmp目录下,并对其进行解压,于是在/tmp下有了gcc-4.1.1目录,它就是gcc-4.1.1的源目录
2、在/tmp下再建立一个gcc-4.1.1-bulid目录,作为gcc-4.1.1的目标目录。
3、在/usr/local下建立gcc-4.1.1-dest目录,作为gcc-4.1.1的配置目录。(需要root权限,所以可以这么做:sudo mkdir /usr/local/gcc-4.1.1-dest)
4、在gcc-4.1.1-bulid目录下(必须的),执行以下命令:
/tmp/gcc-4.1.1/configure --prefix=/usr/local/gcc-4.1.1-dest --enable-threads=posix --disable-checking --enable--long-long --with-system-zlib --enable-languages=c,c++,java(在http://hi.baidu.com/boyliupan/blog/item/3194bb586b259985800a18d2.html上还加了选项:--host=i386-redhat-linux,我不知它是什么意思,而且加了提示找不到i386-redhat-linux,于是没有加,其它选项也不知其意)
5、进行编译,执行: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]: Leaving directory `/tmp/gcc-4.1.1-build/fastjar'
make[2]: *** [all] 错误 2
make[2]: Leaving directory `/tmp/gcc-4.1.1-build/fastjar'
make[1]: *** [all-fastjar] 错误 2
make[1]: Leaving directory `/tmp/gcc-4.1.1-build'
make: *** [all] 错误 2
这不知是什么原因,也不知是什么意思。烦请各位大虾详细指导之,我急用啦。谢谢,感激不尽。
若成功了,我会在贴上继续详细表述安装过程,以方便后来者能够顺利安装,各位顶下吧。谢谢。
(问题解决了很大部分,至少可以保证对C程序编译没问题了,详细过程见我在8、9、10楼发的贴,这是整个问题解决的痛苦历程。最后感谢对我提出宝贵意见的大虾们)
文章评论

共有 13 条评论

  1. a4youma 于 2009-11-18 19:08:50发表:

    好梯子,谢谢~~~

  2. prinse 于 2009-10-15 19:09:05发表:

    引用:
    我的是FC6 为什么用yum install gcc不能用?
    DouglasLau 发表于 2009-10-13 16:27


    啥叫不能用啊?

  3. DouglasLau 于 2009-10-13 16:27:49发表:

    我的是FC6 为什么用yum install gcc不能用?

  4. ziyouhun 于 2009-09-27 11:58:56发表:

    感觉安装linux软件不出问题还好,一出问题头大,对linux看来自己还是不了解,好好学习下,谢谢了

  5. iamxzg 于 2009-09-25 20:00:18发表:

    [i=s] 本帖最后由 iamxzg 于 2009-9-25 20:01 编辑 [/i]

    再也管不着那么多,接着往下做:
    1、查看原来的gcc所在的路径:% which gcc
    显示:/usr/local/ccache/gcc
    /usr/local/ccache/就是原来gcc的目录
    2、把GCC-4.1.1中的gcc、g++等命令在 /usr/local/ccache/目录下分别做一个符号连接:
    > cd /usr/local/ccache/
      > lsudo ln -s /usr/local/gcc-4.1.1-dest/bin/gcc gcc411
      > sudo ln -s /usr/local/gcc-4.1.1-dest/bin/g++ g++411
    由于之前在configure时把java加进去在make时有错误,后来就没加了。
    原则上,这样就可以分别使用gcc411、g++411来调用GCC-4.1.1的gcc、g++j完成对C、C++程序的编译了。同时,仍然能够使用旧版本的GCC编译器中的gcc、g++等命令。
    3、库路径的设置
    将${destdir}/lib路径添加到环境变量LD_LIBRARY_PATH中,最好添加到系统的配置文
    件中,这样就不必要每次都设置这个环境变量了。可以直接在命令行上执行或者在文件/etc/profile中添加下面一句:
    > sudo vi /etc/profile
      setenv LD_LIBRARY_PATH /usr/local/gcc-4.1.1/lib:$LD_LIBRARY_PATH
    4、测试新的编译命令(gcc411、g++411)否能正常工作。
    只要输入命令:gcc411 -v
    若有如下显示,说明是成功的:
    使用内建 specs。
    目标:i686-pc-linux-gnu
    配置为:/tmp/gcc-4.1.1/configure --prefix=/usr/local/gcc-4.1.1-dest --enable-threads=posix --disable-checking --enable--long-long --with-system-zlib --enable-languages=c,c++,java : (reconfigured) /tmp/gcc-4.1.1/configure --prefix=/usr/local/gcc-4.1.1-dest --enable-threads=posix --disable-checking --enable--long-long --with-system-zlib --enable-languages=c,c++
    线程模型:posix
    gcc 版本 4.1.1
    如果还不放心 ,编一个简单的hello.c程序,如
    #include
    int main(void) {printf("hello, Fedora11!\n");}
    编译一下:gcc411 -o hello hello.c
    若有目标hello文件出现,执行./hello,输出:hello, Fedora11!
    不用再怀疑了,一切都OK。
    呀哈,我成功了~!

  6. iamxzg 于 2009-09-25 19:06:18发表:

    先不管了,直接sudo make install,将编译好的库文件等拷贝到配置目录中。完后,/usr/local/gcc-4.1.1-dest下有内容了。当然这是有问题的,截取make install后的部分提示信息如下,希望帮我解决一下。
    ……
    test -z "/usr/local/gcc-4.1.1-dest/lib/gcc/i686-pc-linux-gnu/4.1.1/include" || mkdir -p -- "/usr/local/gcc-4.1.1-dest/lib/gcc/i686-pc-linux-gnu/4.1.1/include"
    /tmp/gcc-4.1.1/install-sh -c -m 644 'ssp/ssp.h' '/usr/local/gcc-4.1.1-dest/lib/gcc/i686-pc-linux-gnu/4.1.1/include/ssp/ssp.h'
    /tmp/gcc-4.1.1/install-sh -c -m 644 '/tmp/gcc-4.1.1/libssp/ssp/string.h' '/usr/local/gcc-4.1.1-dest/lib/gcc/i686-pc-linux-gnu/4.1.1/include/ssp/string.h'
    /tmp/gcc-4.1.1/install-sh -c -m 644 '/tmp/gcc-4.1.1/libssp/ssp/stdio.h' '/usr/local/gcc-4.1.1-dest/lib/gcc/i686-pc-linux-gnu/4.1.1/include/ssp/stdio.h'
    /tmp/gcc-4.1.1/install-sh -c -m 644 '/tmp/gcc-4.1.1/libssp/ssp/unistd.h' '/usr/local/gcc-4.1.1-dest/lib/gcc/i686-pc-linux-gnu/4.1.1/include/ssp/unistd.h'
    make[3]: Leaving directory `/tmp/gcc-4.1.1-build/i686-pc-linux-gnu/libssp'
    make[2]: Leaving directory `/tmp/gcc-4.1.1-build/i686-pc-linux-gnu/libssp'
    make[2]: Entering directory `/tmp/gcc-4.1.1-build/i686-pc-linux-gnu/libiberty'
    make[3]: Entering directory `/tmp/gcc-4.1.1-build/i686-pc-linux-gnu/libiberty/testsuite'
    make[3]: Nothing to be done for `all'.
    make[3]: Leaving directory `/tmp/gcc-4.1.1-build/i686-pc-linux-gnu/libiberty/testsuite'
    make[3]: Entering directory `/tmp/gcc-4.1.1-build/i686-pc-linux-gnu/libiberty'
    ……
    ……
    make[3]: Leaving directory `/tmp/gcc-4.1.1-build/i686-pc-linux-gnu/libiberty'
    make[3]: Entering directory `/tmp/gcc-4.1.1-build/i686-pc-linux-gnu/libiberty/testsuite'
    make[3]: Nothing to be done for `install'.
    make[3]: Leaving directory `/tmp/gcc-4.1.1-build/i686-pc-linux-gnu/libiberty/testsuite'
    make[2]: Leaving directory `/tmp/gcc-4.1.1-build/i686-pc-linux-gnu/libiberty'
    make[1]: Leaving directory `/tmp/gcc-4.1.1-build'
    看到蓝色字体部分,好心痛,却不知从何处下手。

  7. iamxzg 于 2009-09-24 23:17:03发表:

    [i=s] 本帖最后由 iamxzg 于 2009-9-25 20:05 编辑 [/i]

    根据警告:`makeinfo' is missing on your system. You should only need it if
    you modified a `.texi' or `.texinfo' file。
    1、安装texinfo,在/tmp/gcc-4.1.1-bulid目录下输入:
    > sudo yum install texinfo,
    2、安装完毕,查看makeinfo所在目录:
    > where is makeinfo,
    显示:usr/bin/makeinfo。
    3、修改/tmp/gcc-4.1.1-bulid目录下的Makefile,把.../missing makeinfo改成usr/bin/makeinfo.
    4、make。
    经过漫长等待,还是有问题,显示:
    make[4]: Leaving directory `/tmp/gcc-4.1.1-build/i686-pc-linux-gnu/libssp'
    make[3]: Leaving directory `/tmp/gcc-4.1.1-build/i686-pc-linux-gnu/libssp'
    make[2]: Leaving directory `/tmp/gcc-4.1.1-build/i686-pc-linux-gnu/libssp'
    make[1]: Leaving directory `/tmp/gcc-4.1.1-build'
    天啦,何时才到尽头呀。

  8. iamxzg 于 2009-09-24 19:50:40发表:

    输入: /tmp/gcc-4.1.1/configure --prefix=/usr/local/gcc-4.1.1-dest --enable-threads=posix --disable-checking --enable--long-long --with-system-zlib --enable-languages=c,c++,java
    提示:
    loading cache ./config.cache
    checking host system type... i686-pc-linux-gnu
    checking target system type... i686-pc-linux-gnu
    checking build system type... i686-pc-linux-gnu
    checking for a BSD compatible install... (cached) /usr/bin/install -c
    checking whether ln works... (cached) yes
    checking whether ln -s works... (cached) yes
    checking for gcc... (cached) gcc
    checking whether the C compiler (gcc ) works... yes
    checking whether the C compiler (gcc ) is a cross-compiler... no
    checking whether we are using GNU C... (cached) yes
    checking whether gcc accepts -g... (cached) yes
    checking for gnatbind... (cached) gnatbind
    checking whether compiler driver understands Ada... (cached) yes
    checking how to compare bootstrapped objects... (cached) cmp --ignore-initial=16 $$f1 $$f2
    checking for correct version of gmp.h... yes
    checking for MPFR... no
    *** This configuration is not supported in the following subdirectories:
    target-libada gnattools target-libgfortran target-libobjc
    (Any other directories should still work fine.)
    *** removing libiberty/Makefile to force reconfigure
    *** removing zlib/Makefile to force reconfigure
    *** removing fastjar/Makefile to force reconfigure
    checking for bison... (cached) bison -y
    checking for bison... (cached) bison
    checking for gm4... (cached) m4
    checking for flex... (cached) flex
    checking for flex... (cached) flex
    checking for makeinfo... (cached) makeinfo
    checking for expect... no
    checking for runtest... no
    checking for i686-pc-linux-gnu-ar... (cached) ar
    checking for i686-pc-linux-gnu-as... (cached) as
    checking for i686-pc-linux-gnu-dlltool... no
    checking for dlltool... no
    checking for i686-pc-linux-gnu-ld... (cached) ld
    checking for i686-pc-linux-gnu-lipo... no
    checking for lipo... no
    checking for i686-pc-linux-gnu-nm... (cached) nm
    checking for i686-pc-linux-gnu-ranlib... (cached) ranlib
    checking for i686-pc-linux-gnu-strip... (cached) strip
    checking for i686-pc-linux-gnu-windres... no
    checking for windres... no
    checking for i686-pc-linux-gnu-objcopy... (cached) objcopy
    checking for i686-pc-linux-gnu-objdump... (cached) objdump
    checking for i686-pc-linux-gnu-ar... (cached) ar
    checking for i686-pc-linux-gnu-as... (cached) as
    checking for i686-pc-linux-gnu-cc... (cached) cc
    checking for i686-pc-linux-gnu-c++... (cached) c++
    checking for i686-pc-linux-gnu-dlltool... no
    checking for dlltool... no
    checking for i686-pc-linux-gnu-gcc... (cached) gcc
    checking for i686-pc-linux-gnu-gcj... (cached) gcj
    checking for i686-pc-linux-gnu-gfortran... (cached) gfortran
    checking for i686-pc-linux-gnu-ld... (cached) ld
    checking for i686-pc-linux-gnu-lipo... no
    checking for lipo... no
    checking for i686-pc-linux-gnu-nm... (cached) nm
    checking for i686-pc-linux-gnu-objdump... (cached) objdump
    checking for i686-pc-linux-gnu-ranlib... (cached) ranlib
    checking for i686-pc-linux-gnu-strip... (cached) strip
    checking for i686-pc-linux-gnu-windres... no
    checking for windres... no
    checking where to find the target ar... host tool
    checking where to find the target as... host tool
    checking where to find the target cc... just compiled
    checking where to find the target c++... just compiled
    checking where to find the target c++ for libstdc++... just compiled
    checking where to find the target dlltool... host tool
    checking where to find the target gcc... just compiled
    checking where to find the target gcj... just compiled
    checking where to find the target gfortran... host tool
    checking where to find the target ld... host tool
    checking where to find the target lipo... host tool
    checking where to find the target nm... host tool
    checking where to find the target objdump... host tool
    checking where to find the target ranlib... host tool
    checking where to find the target strip... host tool
    checking where to find the target windres... host tool
    checking whether to enable maintainer-specific portions of Makefiles... no
    checking if symbolic links between directories work... (cached) yes
    creating ./config.status
    creating Makefile

  9. iamxzg 于 2009-09-23 23:14:34发表:

    用root也是不行的。。

  10. gzl1100 于 2009-09-23 22:55:05发表:

    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.
    自己看英文,不懂使用翻译工具,非常明显了,缺少依赖包。

  11. wangyu 于 2009-09-23 11:49:16发表:

    用root编译试试

  12. wangyu 于 2009-09-23 08:23:37发表:

    --prefix=/usr/local/gcc-4.1.1-bulid试试,我以前就是看这篇材料编译成功的

  13. nahcoiii 于 2009-09-23 07:47:42发表:

    有没有尝试yum-plugin-allowdowngrade