第四步 编译Glibchttp://oss.ustc.edu.cn/gnu/glibc/glibc-2.9.tar.bz2 http://ftp./pub/clfs/conglomeration/glibc/glibc-ports-2.9.tar.bz2
Glibc也就是C库函数,包括分配内存、搜索目录、打开和关闭文件、读和写文件、字符串操作、模式匹配、代数运算等。 libc-ports软件包的作用是移植,把Glibc库移植到ARM平台时需要它,解压后拷贝到glibc目录,并命名为 ports,就可以了: mv ${PACKAGE_GLIBCPORTS} ${PACKAGE_GLIBC}/ports
编译完成需要时间大概为:1.5小时 配置选项为了使Glibc支持NPTL,需要在Glibc编译目录下建立config.cache文件并写入: cat > config.cache << EOF libc_cv_forced_unwind=yes libc_cv_c_cleanup=yes libc_cv_arm_tls=yes libc_cv_gnu99_inline=yes EOF
其中 libc_cv_arm_tls=yes 可以省略,因为交叉编译环境已经完全了解你要编译的目标体系,所以可以自行检测出来。
BUILD_CC=gcc \ CC=${TARGET}-gcc \ AR=${TARGET}-ar \ RANLIB=${TARGET}-ranlib \ ${SOURCE_DIR}/${PACKAGE_GLIBC}/configure \ --build=${HOST} \ --host=${TARGET} \ --target=${TARGET} \ --prefix="/usr" \ --with-headers=${TARGET_PREFIX}/include \ --with-binutils=${RESULT_DIR}/bin \ --with-tls \ --with-__thread \ --enable-sim \ --enable-nptl \ --enable-add-ons \ --enable-kernel=2.6.29 \ --disable-profile \ --without-gd \ --without-cvs \ --cache-file=config.cache make make install_root=${TARGET_PREFIX} prefix="" install
选项详解BUILD_CC="gcc" Glibc在编译过程中需要先创建一些工具,这些工具需要用主机上的GCC来编译。 CC=${TARGET}-gcc 告诉Glibc使用我们在上一步为ARM目标平台创建的交叉编译器GCC来编译C库。 AR=${TARGET}-ar \ 告诉Glibc使用我们在上一步为ARM目标平台创建的ar来汇编C库。 RANLIB=${TARGET}-ranlib 告诉Glibc使用我们在上一步为ARM目标平台创建的ranlib
-with-headers=${TARGET_PREFIX}/include \ --with-binutils=${RESULT_DIR}/bin This tells Glibc to use the Binutils that are specific to our target architecture.
--with-tls This tells Glibc to use Thread Local Storage.
--with-__thread This tells Glibc to use use the __thread for libc and libpthread builds.
--enable-sim \ --enable-nptl \ --enable-add-ons This tells Glibc to utilize all add-ons that are available.
--enable-kernel=2.6.29 \ --disable-profile This builds the libraries without profiling information. Omit this option if profiling on the temporary tools is necessary.
--without-gd \ --without-cvs \ --cache-file=config.cache This tells Glibc to utilize a premade cache file.
对 prefix 的解释 对 libc.so 的修正· rm ${TARGET_PREFIX}/lib/libc.so cat > ${TARGET_PREFIX}/lib/libc.so << "EOF" /* GNU ld script Use the shared library, but some functions are only in the static library, so try that secondarily. */ OUTPUT_FORMAT(elf32-littlearm) GROUP ( libc.so.6 libc_nonshared.a AS_NEEDED ( ld-linux.so.3 ) ) EOF make install 后得到的文件:(待完善) |
|