During this time, I was using software to implement a 3D graphics library. For some reason, I wanted to use something in c ++ 11. I was forced to compile gcc4.7by myself. A lot of problems were encountered in this process. After unremitting efforts, I finally compiled it successfully. Now I want to record it as a backup. I compiled it on Ubuntu11.10. the following error will be returned: 1. configure error, saying there is no gmp or something. 2. undefinedreferenceto 'lexer _ line' 3
During this time, I was using software to implement a 3D graphics library. For some reason, I wanted to use something in c ++ 11. I was forced to compile gcc4.7by myself. A lot of problems were encountered in this process. After unremitting efforts, I finally compiled it successfully. Now I want to record it as a backup.
I compiled it on Ubuntu11.10. the following error occurs:
1. configure error, saying there is no gmp or something.
2. undefined reference to 'lexer _ Line'
3. fatal error: bits/predefs. h: File or directory not found
4. ld can't find crti. o
The solution is as follows:
1. apt-get install libgmp10-dev libmp fr-dev libmp C-dev
2. apt-get install flex bison
3. 4. Compile the script on the Internet and run it directly.
The following is the script compilation process:
1. Install gmp according to steps 1 and 2 above, and so on;
2. Download the code on the official website in $ HOME/src/gcc-4.7/files/
3. Download the script in the attachment, modify PKG_SNAPSHOT_VER and TARGET_SYSTEM_TYPE, and then run it directly.
4. Follow the script running prompts to complete the final work (such as creating a symbolic link or something)
The script is as follows:
- #! /Bin/sh
- # Filename: build_gcc-snapshot.sh
- # Created: 15 to Mar-2011
- # RunAs: user or root
- # Last Changed: 09-Oct-2011
- ExportLANG=C
- ExportLC_ALL=C
- PKG_NAME="Gcc"
- PKG_VER="4.7"
- PKG_SNAPSHOT_VER=4.7-20120128"
- BASE_DIR="$ HOME/src/$ {PKG_NAME}-$ {PKG_VER }"
- SRC_DIR="$ {BASE_DIR}/$ {PKG_NAME}-$ {PKG_SNAPSHOT_VER }"
- BUILD_DIR="$ {BASE_DIR}/gcc-build"
- DL_DIR="$ {BASE_DIR}/files"
- DL_FILE="Zookeeper pkg_name1_-zookeeper pkg_snapshot_ver=.tar.bz2"
- PATCHES_DIR="$ {BASE_DIR}/patches"
- BUILD_SYSTEM_TYPE= $ (Dpkg-architecture-qDEB_BUILD_GNU_TYPE)
- HOST_SYSTEM_TYPE= $ (Dpkg-architecture-qDEB_HOST_GNU_TYPE)
- TARGET_SYSTEM_TYPE=X86_64-linux-gnu"
- HOST_SYSTEM_MULTIARCH_TYPE= $ (Dpkg-architecture-qDEB_HOST_MULTIARCH)
- PREFIX="/Opt/$ {PKG_NAME}-$ {PKG_VER }"
- LIB_DIR="$ {PREFIX}/lib"
- LIB_EXEC_DIR="$ {PREFIX}/lib"
- BUILD_LOG_FILE="$ {BASE_DIR}/make. log"
- GCC_VER_FOR_BUILD="4.6"
- CC_FOR_BUILD="Gcc-$ {GCC_VER_FOR_BUILD }"
- CXX_FOR_BUILD="G ++-$ {GCC_VER_FOR_BUILD }"
- CPP_FOR_BUILD="Cpp-$ {GCC_VER_FOR_BUILD }"
- ExportCC="$ {CC_FOR_BUILD }" CXX="$ {CXX_FOR_BUILD }" CPP="$ {CPP_FOR_BUILD }"
- Echo "##### CC... $ CC"
- Echo "##### CXX... $ CXX"
- Echo "##### CPP... $ CPP"
- MULTIARCH_FLAGS="-B/usr/lib/$ {HOST_SYSTEM_MULTIARCH_TYPE}-I/usr/include/$ {HOST_SYSTEM_MULTIARCH_TYPE }"
- ExportCFLAGS="-G-O2"
- ExportCXXFLAGS="$ {CFLAGS }"
- ExportCFLAGS_FOR_TARGET="$ {CFLAGS }$ {MULTIARCH_FLAGS }"
- ExportCXXFLAGS_FOR_TARGET="$ {CXXFLAGS }$ {MULTIARCH_FLAGS }"
- ##LD_PRELOAD_FOR_BUILD="$ {PREFIX}/lib/libgcc_s.so.1"
- # ExportLD_PRELOAD=$ {LD_PRELOAD_FOR_BUILD}
- MAKE_JOBS="3"
- Echo "##### MAKE_JOBS... $ {MAKE_JOBS }"
- Test-e $ {BASE_DIR} | mkdir-p $ {BASE_DIR}
- Echo "##### Base directory... $ {BASE_DIR }"
- Echo "##### Unpacking $ {DL_FILE }..."
- Tar-xf $ {DL_DIR}/$ {DL_FILE}-C $ {BASE_DIR}
- Echo "##### Finished unpacking ."
- Test-e $ {BUILD_DIR} | mkdir-p $ {BUILD_DIR}
- Cd $ {BUILD_DIR}
- Echo "##### Build directory... $ PWD"
- # HELP: http://www.linuxfromscratch.org/lfs/view/development/chapter06/gcc.html
- # NOTE: apt-get install libgmp10-dev libmp fr-dev libmp C-dev
- Echo "##### using ing gcc-build ..."
- ../$ {PKG_NAME}-$ {PKG_SNAPSHOT_VER}/configure \
- -- Prefix=$ {PREFIX }\
- -- Libdir=$ {LIB_DIR }\
- -- Libexecdir=$ {LIB_EXEC_DIR }\
- -- Program-suffix=-$ {PKG_VER }\
- -- Enable-clocale=Gnu\
- -- Enable-ages=C, C ++ \
- -- Enable-shared \
- -- Enable-threads=Posix\
- -- Disable-bootstrap \
- -- Disable-libssp \
- -- Disable-multilib \
- -- Disable-nls \
- -- With-system-zlib \
- -- Without-cloog \
- -- Without-ppl \
- -- With-arch-32=I586 -- With-tune=Generic\
- -- Build=$ {BUILD_SYSTEM_TYPE}-- Host=$ {HOST_SYSTEM_TYPE}-- Target=$ {TARGET_SYSTEM_TYPE}
- Echo "##### Finished sorting ."
- Echo "##### Compiling gcc-build ..."
- MakeFLAGS_FOR_TARGET="$ {FLAGS_FOR_TARGET }$ {MULTIARCH_FLAGS }"-J $ {MAKE_JOBS} 2>& 1 | tee $ {BUILD_LOG_FILE}
- Echo "##### Finished compiling ."
- Echo "NOTE #1: Before installing your shiny new gcc run the gcc-testsuite to check your build is OK! "
- Echo "NOTE #2: Don't forget to generate symlinks in system's bin directory! "
- Echo "EXAMPLE: sudo ln-sf $ {PREFIX}/bin/$ {PKG_NAME}-$ {PKG_VER}/usr/bin/$ {PKG_NAME}-$ {PKG_VER }"
- Echo "NOTE #3: Don't forget to add $ {PREFIX}/lib 'to/etc/ld. so. conf. d/$ {TARGET_SYSTEM_TYPE}. conf! "
- Echo "EXAMPLE: sudo ldconfig-v"