打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
[原创]自己动手制作交叉编译工具链(6)

第五步 编译GCC(第二次)

需要时间大概为:1小时

配置选项

这次是编译完整的GCC,因此第一次disable的一些选项这次可以enable了。

${SOURCE_DIR}/${PACKAGE_GCC}/configure \

   --build=${HOST} \

   --host=${HOST} \

   --target=${TARGET} \

   --prefix=${RESULT_DIR} \

   --with-float=soft \

   --with-cpu=arm920t \

   --with-tune=arm9tdmi \

   --enable-languages=c,c++ \

   --enable-threads=posix \

   --enable-c99 \

   --enable-long-long \

   --enable-shared \

   --enable-__cxa_atexit \

   --enable-nls \

   --disable-libgomp

make && make install

选项详解

-enable-languages=c,c++

This option ensures that only the C and C++ compilers are built.

--enable-__cxa_atexit

Thisoption allows use of __cxa_atexit, rather than atexit, to register C++destructors for local statics and global objects and is essential forfully standards-compliant handling of destructors. It also affects theC++ ABI and therefore results in C++ shared libraries and C++ programsthat are interoperable with other Linux distributions.

--enable-c99

Enable C99 support for C programs.

--enable-long-long

Enables long long support in the compiler.

--enable-threads=posix

This enables C++ exception handling for multi-threaded code.

--enable-nls \

--disable-libgomp

如果不加这一项会出现如下错误:

configure: error: Pthreads are required to build libgomp
make[1]: *** [configure-target-libgomp] 错误 1
make[1]:
正在离开目录
`/home/hongwang/mktoolchain/build/gcc-4.4.0-2'
make: *** [all]
错误
2
没有找到好的解决办法,只能在configure里增加
--disable-libgomp

为什么要编译两次GCC

第一遍只编译一个支持cgcc,原因是要编译出一个支持交叉的c++,必须有一个编译好的用于目标体系平台的glibc,而不是只有glibc的头文件就可以的,好在编译glibcc支持就够了,所以编译glibc也成了第一遍的gcc唯一的理由和作用。工具链中gcc的第一次和第二次编译都是由主系统的gccbinutils来完成的(之前没有提及binutils,只是为了理解方便,但实际上编译后是少不了链接过程的,这个过程是要binutils来完成的)。到目前为止只有在编译glibc的时候用到了交叉版本的binutils,其它部分的链接都是由主系统的binutils来完成的。
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
CLFS2.0学习
交叉编译gcc
arm-linux-gcc 3.4.4
Cross Toolchain-交叉编译工具链
Linux下C开发环境的构成和安装
编译工具和交叉编译环境配置
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服