您尚未登录。

楼主 # 2022-02-08 20:10:30

Sam
会员
注册时间: 2019-12-06
已发帖子: 55
积分: 55

gcc 链接脚本 group /DISCARD/

移植Liteos时编译报错,报错内容:

g:/keil_v5/arm/gcc-arm-9.2-2019.12-mingw-w64-i686-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe: g:/keil_v5/arm/gcc-arm-9.2-2019.12-mingw-w64-i686-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/9.2.1\libc.a(lib_a-fstatr.o): in function `_fstat_r':
/tmp/lto_build/src/newlib-cygwin/newlib/libc/reent/fstatr.c(55): error: undefined reference to `_fstat'
g:/keil_v5/arm/gcc-arm-9.2-2019.12-mingw-w64-i686-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe: g:/keil_v5/arm/gcc-arm-9.2-2019.12-mingw-w64-i686-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/9.2.1\libc.a(lib_a-sbrkr.o): in function `_sbrk_r':
/tmp/lto_build/src/newlib-cygwin/newlib/libc/reent/sbrkr.c(51): error: undefined reference to `_sbrk'
g:/keil_v5/arm/gcc-arm-9.2-2019.12-mingw-w64-i686-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe: g:/keil_v5/arm/gcc-arm-9.2-2019.12-mingw-w64-i686-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/9.2.1\libc.a(lib_a-writer.o): in function `_write_r':
/tmp/lto_build/src/newlib-cygwin/newlib/libc/reent/writer.c(49): error: undefined reference to `_write'
g:/keil_v5/arm/gcc-arm-9.2-2019.12-mingw-w64-i686-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe: g:/keil_v5/arm/gcc-arm-9.2-2019.12-mingw-w64-i686-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/9.2.1\libc.a(lib_a-closer.o): in function `_close_r':
/tmp/lto_build/src/newlib-cygwin/newlib/libc/reent/closer.c(47): error: undefined reference to `_close'
g:/keil_v5/arm/gcc-arm-9.2-2019.12-mingw-w64-i686-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe: g:/keil_v5/arm/gcc-arm-9.2-2019.12-mingw-w64-i686-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/9.2.1\libc.a(lib_a-isattyr.o): in function `_isatty_r':
/tmp/lto_build/src/newlib-cygwin/newlib/libc/reent/isattyr.c(52): error: undefined reference to `_isatty'
g:/keil_v5/arm/gcc-arm-9.2-2019.12-mingw-w64-i686-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe: g:/keil_v5/arm/gcc-arm-9.2-2019.12-mingw-w64-i686-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/9.2.1\libc.a(lib_a-lseekr.o): in function `_lseek_r':
/tmp/lto_build/src/newlib-cygwin/newlib/libc/reent/lseekr.c(49): error: undefined reference to `_lseek'
g:/keil_v5/arm/gcc-arm-9.2-2019.12-mingw-w64-i686-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe: g:/keil_v5/arm/gcc-arm-9.2-2019.12-mingw-w64-i686-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/9.2.1\libc.a(lib_a-readr.o): in function `_read_r':
/tmp/lto_build/src/newlib-cygwin/newlib/libc/reent/readr.c(49): error: undefined reference to `_read'

在链接脚本中加入

   /DISCARD/ :
  {
    libc.a ( * )
    libnosys.a ( * )
    libgcc.a ( * )
  }

或者

  group :
  {
    libc.a ( * )
    libnosys.a ( * )
    libgcc.a ( * )
  }

然后就没问题了,求解/DISCARD/ 和 group 是什么意思,求大神指点:)

离线

页脚

工信部备案:粤ICP备20025096号 Powered by FluxBB

感谢为中文互联网持续输出优质内容的各位老铁们。 QQ: 516333132, 微信(wechat): whycan_cn (哇酷网/挖坑网/填坑网) service@whycan.cn