移植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 是什么意思,求大神指点:)
离线