EmbDev.net

Forum: ARM programming with GCC/GNU tools getting errors while trying to compile


Author: John Youkhana (jyoukhana)
Posted on:

Rate this post
0 useful
not useful
I downloaded the already built arm-elf-gcc compiler and when i try to
compile a simple c program i get the following errors.

/root/Desktop/arm/bin/../lib/gcc/arm-elf/4.1.0/../../../../arm-elf/lib/l 
ibc.a(mallocr.o):
In function `_malloc_r':
../../../../../../src/newlib-1.14.0/newlib/libc/stdlib/mallocr.c:2160:
undefined reference to `_sbrk_r'
../../../../../../src/newlib-1.14.0/newlib/libc/stdlib/mallocr.c:2197:
undefined reference to `_sbrk_r'
/root/Desktop/arm/bin/../lib/gcc/arm-elf/4.1.0/../../../../arm-elf/lib/l 
ibc.a(stdio.o):
In function `__sclose':
../../../../../../src/newlib-1.14.0/newlib/libc/stdio/stdio.c:120:
undefined reference to `_close_r'
/root/Desktop/arm/bin/../lib/gcc/arm-elf/4.1.0/../../../../arm-elf/lib/l 
ibc.a(stdio.o):
In function `__sseek':
../../../../../../src/newlib-1.14.0/newlib/libc/stdio/stdio.c:103:
undefined reference to `_lseek_r'
/root/Desktop/arm/bin/../lib/gcc/arm-elf/4.1.0/../../../../arm-elf/lib/l 
ibc.a(stdio.o):
In function `__swrite':
../../../../../../src/newlib-1.14.0/newlib/libc/stdio/stdio.c:76:
undefined reference to `_lseek_r'
../../../../../../src/newlib-1.14.0/newlib/libc/stdio/stdio.c:84:
undefined reference to `_write_r'
/root/Desktop/arm/bin/../lib/gcc/arm-elf/4.1.0/../../../../arm-elf/lib/l 
ibc.a(stdio.o):
In function `__sread':
../../../../../../src/newlib-1.14.0/newlib/libc/stdio/stdio.c:47:
undefined reference to `_read_r'
/root/Desktop/arm/bin/../lib/gcc/arm-elf/4.1.0/../../../../arm-elf/lib/l 
ibc.a(freer.o):
In function `_malloc_trim_r':
../../../../../../src/newlib-1.14.0/newlib/libc/stdlib/mallocr.c:3326:
undefined reference to `_sbrk_r'
../../../../../../src/newlib-1.14.0/newlib/libc/stdlib/mallocr.c:3335:
undefined reference to `_sbrk_r'
../../../../../../src/newlib-1.14.0/newlib/libc/stdlib/mallocr.c:3340:
undefined reference to `_sbrk_r'
collect2: ld returned 1 exit status

Im using CentOS 5.

Author: Martin Thomas (mthomas) (Moderator)
Posted on:

Rate this post
0 useful
not useful
John Youkhana wrote:
> I downloaded the already built arm-elf-gcc compiler and when i try to
> compile a simple c program i get the following errors.

I guess the "simple c program" is something like

#include <stdio.h>
int main(void) {
  printf("Hello world\n");
  return 0;
}

Please try to start with a blinking-LED program and keep functions from
stdio like printf for later experiments.

>
> /root/Desktop/arm/bin/../lib/gcc/arm-elf/4.1.0/../../../../arm-elf/lib/l 
ibc.a(mallocr.o):
> In function `_malloc_r':
> ../../../../../../src/newlib-1.14.0/newlib/libc/stdlib/mallocr.c:2160:
> undefined reference to `_sbrk_r'
>...

Try a forum-search with sbrk, read about newlib-syscalls, read the ARM
"bare-metal" tutorial from Quantum Leaps.

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.