0

I am trying to compile a thumb code using gcc (from GNU Tools ARM Embedded).

by typing the command line gcc.exe C:\foo.c -o foo.o -mthumb I get the following errors:

c:/program files (x86)/gnu tools arm embedded/5.2 2015q4/bin/../lib/gcc/arm-none-eabi/5.2.1/../../../../arm-none-eabi/lib/thumb\libc.a(lib_a-exit.o): In function exit': exit.c:(.text.exit+0x1a): undefined reference to_exit' c:/program files (x86)/gnu tools arm embedded/5.2 2015q4/bin/../lib/gcc/arm-none-eabi/5.2.1/../../../../arm-none-eabi/lib/thumb\libc.a(lib_a-sbrkr.o): In function _sbrk_r': sbrkr.c:(.text._sbrk_r+0xc): undefined reference to_sbrk' c:/program files (x86)/gnu tools arm embedded/5.2 2015q4/bin/../lib/gcc/arm-none-eabi/5.2.1/../../../../arm-none-eabi/lib/thumb\libc.a(lib_a-writer.o): In function _write_r': writer.c:(.text._write_r+0x10): undefined reference to_write' c:/program files (x86)/gnu tools arm embedded/5.2 2015q4/bin/../lib/gcc/arm-none-eabi/5.2.1/../../../../arm-none-eabi/lib/thumb\libc.a(lib_a-closer.o): In function _close_r': closer.c:(.text._close_r+0xc): undefined reference to_close' c:/program files (x86)/gnu tools arm embedded/5.2 2015q4/bin/../lib/gcc/arm-none-eabi/5.2.1/../../../../arm-none-eabi/lib/thumb\libc.a(lib_a-lseekr.o): In function _lseek_r': lseekr.c:(.text._lseek_r+0x10): undefined reference to_lseek' c:/program files (x86)/gnu tools arm embedded/5.2 2015q4/bin/../lib/gcc/arm-none-eabi/5.2.1/../../../../arm-none-eabi/lib/thumb\libc.a(lib_a-readr.o): In function _read_r': readr.c:(.text._read_r+0x10): undefined reference to_read' c:/program files (x86)/gnu tools arm embedded/5.2 2015q4/bin/../lib/gcc/arm-none-eabi/5.2.1/../../../../arm-none-eabi/lib/thumb\libc.a(lib_a-fstatr.o): In function _fstat_r': fstatr.c:(.text._fstat_r+0xe): undefined reference to_fstat' c:/program files (x86)/gnu tools arm embedded/5.2 2015q4/bin/../lib/gcc/arm-none-eabi/5.2.1/../../../../arm-none-eabi/lib/thumb\libc.a(lib_a-isattyr.o): In function _isatty_r': isattyr.c:(.text._isatty_r+0xc): undefined reference to_isatty' collect2.exe: error: ld returned 1 exit status

How can I solve these errors?

ASmith
  • 21
  • 2
  • 1
    Possible duplicate of [Compiling basic C file for the ARM processor](http://stackoverflow.com/questions/9632595/compiling-basic-c-file-for-the-arm-processor) – Notlikethat Mar 07 '16 at 08:49
  • Still cannot solve the problem according to the solution... – ASmith Mar 08 '16 at 09:08
  • The solution is to implement (or pull in from your vendor's BSP code, as appropriate) the necessary functions - I can pretty much guarantee that it'll link successfully if they correctly exist. This is a bare-metal toolchain; in the absence of an OS [you have to handle the C library's "system call" requests yourself](https://sourceware.org/newlib/libc.html#Stubs). – Notlikethat Mar 08 '16 at 09:30

0 Answers0