getting errors while trying to compile

OP #1174648
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.
Moderator
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

A question of your own? This thread is over 17 years old. Ask it in a thread of its own – more people read along there, and it gets answered more often and sooner.

Start a new thread

A fix, an addition or feedback on this thread? Then reply here.

Formatting
  • [c]C-Code[/c]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.