EmbDev.net

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


von John Y. (jyoukhana)


Rate this post
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.

von Martin T. (mthomas) (Moderator)


Rate this post
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.

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.