升级 GCC 4.5.0

下面是编译脚本(具体参考LFS和GCC-configure)

# download
wget http://www.multiprecision.org/mpc/download/mpc-0.8.1.tar.gz
wget http://ftp.gnu.org/gnu/gcc/gcc-4.5.0/gcc-4.5.0.tar.bz2
wget http://ftp.gnu.org/gnu/gmp/gmp-5.0.1.tar.bz2
wget http://www.mpfr.org/mpfr-2.4.2/mpfr-2.4.2.tar.bz2

# tools PATH; use your own setting
ROOTDIR=/work/tools/stesen/tools
mkdir -pv $ROOTDIR
ln -svf $ROOTDIR /

# optimization(core2 T7250,运算速度优化参数)
CFLAGS="-march=native -mfpmath=sse,387 -minline-all-stringops -pipe -O3 -fomit-frame-pointer -fforce-addr -finline-functions -finline-limit=800-fmove-all-movables -freduce-all-givs -freorder-blocks-freorder-functions -fexpensive-optimizations -falign-functions-falign-labels -falign-loops -falign-jumps -frename-registers -fweb-funit-at-a-time -funroll-loops -fprefetch-loop-arrays-ffunction-sections -fdata-sections -fbranch-target-load-optimize-fbranch-target-load-optimize2" && CXXFLAGS=CFLAGS

###########################################################
# 64位cpu装32位系统的用此CFLAGS可能会导致编译失败
# 指定ABI可以解决,或者使用系统的gmp,mpfr,gpc
# aptitude install libgmp3-dev libmpfr-dev libmpc2 libmpc-dev
# configure时不指定--with-XXX=/tools

############################################################

# gmp

tar xvf gmp-5.0.1.tar.bz2

cd gmp-5.0.1/

./configure --prefix=/tools --enable-cxx --enable-mpbsd

make -j3

make install

cd ..

rm -fr gmp-5.0.1

 


# mpfr

tar xf mpfr-2.4.2.tar.bz2

cd mpfr-2.4.2/

./configure --prefix=/tools --enable-thread-safe --with-gmp=/tools

make -j3

make install

cd ..

rm -fr mpfr-2.4.2

 


# mpc

tar xvf mpc-0.8.1.tar.gz

cd mpc-0.8.1/

./configure --with-mpfr=/tools --with-gmp=/tools --prefix=/tools

make -j3

make install

cd ..

rm -fr mpc-0.8.1

 


# gcc

tar xvf gcc-4.5.0.tar.bz2

cd gcc-4.5.0/

mkdir -v ../gcc-build

cd ../gcc-build

../gcc-4.5.0/configure --prefix=/tools --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --enable-languages=c,c++ --disable-multilib --disable-bootstrap --with-gmp=/tools --with-mpfr=/tools --with-mpc=/tools

make -j3

make install

cd ..

rm -fr gcc-build

rm -fr gcc-4.5.0

export PATH=/tools/bin:$PATH

gcc -v

 

 

出现的问题

/usr/src/gcc4/gcc-4.4.1/host-i686-pc-linux-gnu/gcc/../.././gcc/builtins.c:10291: undefined reference to `mpfr_j0'
/usr/src/gcc4/gcc-4.4.1/host-i686-pc-linux-gnu/gcc/../.././gcc/builtins.c:10297: undefined reference to `mpfr_j1'
/usr/src/gcc4/gcc-4.4.1/host-i686-pc-linux-gnu/gcc/../.././gcc/builtins.c:10303: undefined reference to `mpfr_y0'
/usr/src/gcc4/gcc-4.4.1/host-i686-pc-linux-gnu/gcc/../.././gcc/builtins.c:10309: undefined reference to `mpfr_y1'
错误提示:
 
libbackend.a(builtins.o): In function `fold_builtin_2':
/usr/src/gcc4/gcc-4.4.1/host-i686-pc-linux-gnu/gcc/../.././gcc/builtins.c:10430: undefined reference to `mpfr_jn'
/usr/src/gcc4/gcc-4.4.1/host-i686-pc-linux-gnu/gcc/../.././gcc/builtins.c:10436: undefined reference to `mpfr_yn'
/usr/src/gcc4/gcc-4.4.1/host-i686-pc-linux-gnu/gcc/../.././gcc/builtins.c:10444: undefined reference to `mpfr_remainder'
libbackend.a(builtins.o): In function `do_mpfr_remquo':
/usr/src/gcc4/gcc-4.4.1/host-i686-pc-linux-gnu/gcc/../.././gcc/builtins.c:13344: undefined reference to `mpfr_remquo'
libbackend.a(builtins.o): In function `do_mpfr_lgamma_r':
/usr/src/gcc4/gcc-4.4.1/host-i686-pc-linux-gnu/gcc/../.././gcc/builtins.c:13422: undefined reference to `mpfr_lgamma'
collect2: ld returned 1 exit status
make[3]: *** [cc1-dummy] Error 1
make[3]: Leaving directory `/usr/src/gcc4/gcc-4.4.1/host-i686-pc-linux-gnu/gcc'
make[2]: *** [all-stage1-gcc] Error 2
make[2]: Leaving directory `/usr/src/gcc4/gcc-4.4.1'
make[1]: *** [stage1-bubble] Error 2
make[1]: Leaving directory `/usr/src/gcc4/gcc-4.4.1'
make: *** [all] Error 2
 
这个是无法链接到mpfr和gmp的lib导致的,但是明明是安装了mpfr和gmp的。原因在于配置文件的错误,
 
解决:
 
1.把Makefile中的GMPLIBS = -lmpfr -lgmp 改成GMPLIBS = -L/usr/local/lib -lmpfr -lgmp
这里的/usr/local/lib是我的库安装目录。
2.while building , add gmp and mpfr installation path in LD_LIBRARY_PATH environment variable. Do as follows

export LD_LIBRARY_PATH=/usr/local/gmp-4.1.3/lib:/usr/local/mpfr-2.3.2/lib:$LD_LIBRARY_PATH

I hope this will resolve the problem , and “make” will continue.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值