安装gcc及其依赖

简介: 在gcc-4.8.2和gcc-4.1.2基础上编译gcc-5.2.0,有可能会遇到一些问题。 要想成功编译gcc,则在编译之前需要安装好它的至少以下三个依赖: gmp mpfr mpc 而mpc又依赖gmp和mpfr。
在gcc-4.8.2和gcc-4.1.2基础上编译gcc-5.2.0,有可能会遇到一些问题。


要想成功编译gcc,则在编译之前需要安装好它的至少以下三个依赖:
gmp
mpfr
mpc


而mpc又依赖gmp和mpfr。


1) 安装gmp
./configure --prefix=/usr/local/gmp-6.0.0
make
make install


2) 安装mpfr
./configure --prefix=/usr/local/mpfr-3.1.3
make
make install


3) 安装mpc
./configure --prefix=/usr/local/mpc-1.0.3 --with-gmp=/usr/local/gmp-6.0.0 --with-mpfr=/usr/local/mpfr-3.1.3
make
make install


为了成功的编译gcc,建议设置环境变量:
export LD_LIBRARY_PATH=/usr/local/mpc-1.0.3/lib:/usr/local/gmp-6.0.0/lib:/usr/local/mpfr-3.1.3/lib:$LD_LIBRARY_PATH


4) 安装gcc-5.2.0
./configure --prefix=/data/gcc-5.2.0 --with-mpfr=/usr/local/mpfr-3.1.3 --with-gmp=/usr/local/gmp-6.0.0 --with-mpc=/usr/local/mpc-1.0.3
make
make install


4) 安装gcc-4.8.2
./configure --prefix=/data/gcc-4.8.2 --with-mpfr=/usr/local/mpfr-3.1.3 --with-gmp=/usr/local/gmp-6.0.0 --with-mpc=/usr/local/mpc-1.0.3
make
make install


常见错误:
错误1)
configure: error: C compiler cannot create executables
请尝试设置下LD_LIBRARY_PATH后,再执行configure,再make:
export LD_LIBRARY_PATH=/usr/local/mpc-1.0.3/lib:/usr/local/gmp-6.0.0/lib:/usr/local/mpfr-3.1.3/lib:$LD_LIBRARY_PATH


错误2)
../.././libgcc/config/t-softfp:106: 在“else”指令之后含有不该出现的文字
../.././libgcc/config/t-softfp:113: *** 每个条件只能有一个“else”。 停止。


首先通过find命令找到t-softfp(注意是config目录下的t-softfp):
find . -name "t-softfp" 


然后进入t-softfp的第106行:
vi ./libgcc/config/t-softfp


 98 ifeq ($(enable_shared),yes)
 99     $(call softfp_set_symver,__$(*F))
100     if grep strong_alias $(srcdir)/soft-fp/$@ > /dev/null; then \
101       alias=`grep strong_alias $(srcdir)/soft-fp/$@ | sed -e 's/.*, *//' -e 's/).*//'`; \
102       $(call softfp_set_symver,$$alias); \
103     fi
104 endif
105     echo '#endif' >> $@
106 else ifneq ($(softfp_wrap_start),)
107 softfp_file_list := $(addsuffix .c,$(softfp_func_list))
108 
109 $(softfp_file_list):
110     echo $(softfp_wrap_start) > $@
111     echo '#include "soft-fp/$@"' >> $@
112     echo $(softfp_wrap_end) >> $@
113 else
114 softfp_file_list := \
115   $(addsuffix .c,$(addprefix $(srcdir)/soft-fp/,$(softfp_func_list)))
116 endif


将文件t-softfp的第106行变成两行:
else
    ifneq ($(softfp_wrap_start),)


错误3)
../.././libgcc/config/t-softfp:144: *** 遗漏“endif”。 停止。


第144行已是文件t-softfp的最后一行:
139 LIB2FUNCS_EXCLUDE += \
140   $(addprefix _,$(foreach m,$(softfp_float_modes), \
141                             $(foreach i,si di, \
142                                         $(softfp_floatint_funcs))))
143 endif


按照出错提示增加第144行:
143 endif
144 endif


错误4)使用gcc-4.1.2编译gcc-5.2.0时,遇到如下错误:
checking for suffix of object files... configure: error: in `/data/gcc-5.2.0/x86_64-unknown-linux-gnu/libgcc':
configure: error: cannot compute suffix of object files: cannot compile
See `config.log' for more details.
依据错误提示,在config.log中找到如下一些信息:
| #if (__GNUC__ | #error -static-libstdc++ not implemented
| #endif
这表示用于编译gcc-5.2.0的gcc版本偏低,至少需gcc-4.5版本。

相关文章
|
2月前
|
编译器 Linux 开发工具
|
18天前
|
自然语言处理 编译器 Go
GCC:GNU编译器
GCC:GNU编译器
17 0
|
18天前
|
Java 编译器 Linux
技术经验解读:【转载】详解GCC的下载和安装(源码安装)
技术经验解读:【转载】详解GCC的下载和安装(源码安装)
11 0
|
28天前
|
C语言
关于如何解决mingw64安装后配置完环境变量仍然执行不了gcc命令
关于如何解决mingw64安装后配置完环境变量仍然执行不了gcc命令
|
2月前
|
C语言
gcc的简易用法(编译、参数与链接)
【5月更文挑战第14天】gcc的简易用法(编译、参数与链接)。
25 1
|
2月前
|
Unix Java 编译器
安装gcc
【5月更文挑战第14天】安装gcc。
51 1
|
2月前
|
NoSQL 编译器 开发工具
006.gcc编译器
gcc是什么?
61 0
006.gcc编译器
|
2月前
|
存储 NoSQL 算法
从一个crash问题展开,探索gcc编译优化细节
问题分析的过程也正是技术成长之路,本文以一个gcc编译优化引发的crash为切入点,逐步展开对编译器优化细节的探索之路,在分析过程中打开了新世界的大门……
527 1
|
2月前
|
C语言
gcc的简易用法
【5月更文挑战第10天】gcc的简易用法。
32 8
|
2月前
|
C语言
转载 - gcc/ld 动态连接库和静态连接库使用方法
本文介绍了如何在GCC中实现部分程序静态链接、部分动态链接。使用`-Wl`标志传递链接器参数,`-Bstatic`强制链接静态库,`-Bdynamic`强制链接动态库。
57 0