The following is a compilation script (For details, refer to LFS and GCC-configure)
# Downloadwget http://www.multiprecision.org/mpc/download/mpc-0.8.1.tar.gzwget http://ftp.gnu.org/gnu/gcc/gcc-4.5.0/gcc-4.5.0.tar.bz2wget http://ftp.gnu.org/gnu/gmp/gmp-5.0.1.tar.bz2wget http://www.mpfr.org/mpfr-2.4.2/mpfr-2.4.2.tar.bz2
# Tools path; use your own settingrootdir =/work/tools/stesen/toolsmkdir-PV $ rootdirln-SVF $ rootdir/
# Optimization (core2 t7250, operation speed Optimization Parameter) 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
######################################## ################### Use this cflags to install a 32-bit 64-bit CPU system may cause compilation failure # specify Abi solution, or use the system's GMP, mpfr, GPC # aptitude install libgmp3-dev libmp fr-dev libmpc2 libmp C-dev # configure without specifying -- 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 ages = C, c ++ -- disable-multilib -- disable-Bootstrap -- With-GMP =/tools -- With-mpfr =/tools -- With-nm=/tools
Make-J3
Make install
CD ..
Rm-fr gcc-build
Rm-fr gcc-4.5.0
Export Path =/tools/bin: $ path
Gcc-V
Problems
/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'
Error message: 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, which is caused by the failure to link to mpfr and GMP Lib, but mpfr and GMP are obviously installed. The reason is that the configuration file is incorrect. Solution: 1. change gmplibs =-lmpfr-lgmp in makefile to gmplibs =-L/usr/local/lib-lmpfr-lgmp. Here/usr/local/lib is the installation directory of my library. 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_pathi hope this will resolve the problem, and "make" will continue.