Link problem of arm-none-eabi-gcc

Asked by yu

Hi all,

I have installed arm-none-eabi-gcc on windows and linux(Ubuntu), but I encounter the same link problem.
Do you know what is wrong?

Thank you very much!

yu@ubuntu:~/cc$ arm-none-eabi-gcc hello.c
/home/yu/toolchain/gcc-arm-none-eabi-5_4-2016q3-20160926/install-native/lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/lib/libc.a(lib_a-exit.o): In function `exit':
/home/yu/toolchain/gcc-arm-none-eabi-5_4-2016q3-20160926/src/newlib/newlib/libc/stdlib/exit.c:70: undefined reference to `_exit'
/home/yu/toolchain/gcc-arm-none-eabi-5_4-2016q3-20160926/install-native/lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/lib/libc.a(lib_a-sbrkr.o): In function `_sbrk_r':
/home/yu/toolchain/gcc-arm-none-eabi-5_4-2016q3-20160926/src/newlib/newlib/libc/reent/sbrkr.c:58: undefined reference to `_sbrk'
/home/yu/toolchain/gcc-arm-none-eabi-5_4-2016q3-20160926/install-native/lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/lib/libc.a(lib_a-writer.o): In function `_write_r':
/home/yu/toolchain/gcc-arm-none-eabi-5_4-2016q3-20160926/src/newlib/newlib/libc/reent/writer.c:58: undefined reference to `_write'
/home/yu/toolchain/gcc-arm-none-eabi-5_4-2016q3-20160926/install-native/lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/lib/libc.a(lib_a-closer.o): In function `_close_r':
/home/yu/toolchain/gcc-arm-none-eabi-5_4-2016q3-20160926/src/newlib/newlib/libc/reent/closer.c:53: undefined reference to `_close'
/home/yu/toolchain/gcc-arm-none-eabi-5_4-2016q3-20160926/install-native/lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/lib/libc.a(lib_a-fstatr.o): In function `_fstat_r':
/home/yu/toolchain/gcc-arm-none-eabi-5_4-2016q3-20160926/src/newlib/newlib/libc/reent/fstatr.c:62: undefined reference to `_fstat'
/home/yu/toolchain/gcc-arm-none-eabi-5_4-2016q3-20160926/install-native/lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/lib/libc.a(lib_a-isattyr.o): In function `_isatty_r':
/home/yu/toolchain/gcc-arm-none-eabi-5_4-2016q3-20160926/src/newlib/newlib/libc/reent/isattyr.c:58: undefined reference to `_isatty'
/home/yu/toolchain/gcc-arm-none-eabi-5_4-2016q3-20160926/install-native/lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/lib/libc.a(lib_a-lseekr.o): In function `_lseek_r':
/home/yu/toolchain/gcc-arm-none-eabi-5_4-2016q3-20160926/src/newlib/newlib/libc/reent/lseekr.c:58: undefined reference to `_lseek'
/home/yu/toolchain/gcc-arm-none-eabi-5_4-2016q3-20160926/install-native/lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/lib/libc.a(lib_a-readr.o): In function `_read_r':
/home/yu/toolchain/gcc-arm-none-eabi-5_4-2016q3-20160926/src/newlib/newlib/libc/reent/readr.c:58: undefined reference to `_read'
collect2: error: ld returned 1 exit status

Question information

Language:
English Edit question
Status:
Solved
For:
GNU Arm Embedded Toolchain Edit question
Assignee:
No assignee Edit question
Solved by:
Thomas Preud'homme
Solved:
Last query:
Last reply:
Revision history for this message
Best Thomas Preud'homme (thomas-preudhomme) said :
#1

Hi Yu,

If you want to use semihosting, you should add -specs=rdimon.specs on the command line. Otherwise, define those that makes sense to you (ie. if you wanna use printf you'll have to define _write, any malloc will need _sbrk, etc.) and then link with -specs=nosys to silence the other warnings.

Best regards.

Revision history for this message
yu (peace567) said :
#2

Thanks Thomas Preud'homme, that solved my question.