GCC linking and compiling error for Cortex-M3 Microcontroller because of Newlib

deut3892 deut831@hotmail.com
Sun Jan 9 19:12:00 GMT 2011


Hello,

Please forgive me if my post is in an incorrect place. This seems to be the
most appropriate place for it since it is about gcc.

I have followed the instructions here:
http://johannes-bauer.com/mcus/cortex/

Basically, I have setup the gcc cross compiler in Ubuntu 10.10 for the
Cortex-M3 compiler. I've also added GDB and eclipse. Compilation of a simple
hello world program works just fine, but when I need to compile more
advanced programs that use malloc and other features that are part of newlib
fails.

Newlib was compiled as:
newlib-1.18.0/configure --target=${BLD_TARGET} --prefix=${BLD_PREFIX}
--disable-multilib --disable-newlib-supplied-syscalls --disable-interwork

therefore, my understanding is I have to supply my own newlib. When I am
compiling and linking I get the following errors:

/home/ops/bin/arm-elf/lib/gcc/arm-elf/4.4.3/../../../../arm-elf/lib/libc.a(lib_a-sbrkr.o):
In function `_sbrk_r':
/home/ops/Desktop/arm-toolchain/newlib/arm-elf/newlib/libc/reent/../../../../newlib-1.18.0/newlib/libc/reent/sbrkr.c:60:
undefined reference to `_sbrk'
/home/ops/bin/arm-elf/lib/gcc/arm-elf/4.4.3/../../../../arm-elf/lib/libc.a(lib_a-writer.o):
In function `_write_r':
/home/ops/Desktop/arm-toolchain/newlib/arm-elf/newlib/libc/reent/../../../../newlib-1.18.0/newlib/libc/reent/writer.c:58:
undefined reference to `_write'
/home/ops/bin/arm-elf/lib/gcc/arm-elf/4.4.3/../../../../arm-elf/lib/libc.a(lib_a-closer.o):
In function `_close_r':
/home/ops/Desktop/arm-toolchain/newlib/arm-elf/newlib/libc/reent/../../../../newlib-1.18.0/newlib/libc/reent/closer.c:53:
undefined reference to `_close'
/home/ops/bin/arm-elf/lib/gcc/arm-elf/4.4.3/../../../../arm-elf/lib/libc.a(lib_a-lseekr.o):
In function `_lseek_r':
/home/ops/Desktop/arm-toolchain/newlib/arm-elf/newlib/libc/reent/../../../../newlib-1.18.0/newlib/libc/reent/lseekr.c:58:
undefined reference to `_lseek'
/home/ops/bin/arm-elf/lib/gcc/arm-elf/4.4.3/../../../../arm-elf/lib/libc.a(lib_a-readr.o):
In function `_read_r':
/home/ops/Desktop/arm-toolchain/newlib/arm-elf/newlib/libc/reent/../../../../newlib-1.18.0/newlib/libc/reent/readr.c:58:
undefined reference to `_read'
/home/ops/bin/arm-elf/lib/gcc/arm-elf/4.4.3/../../../../arm-elf/lib/libc.a(lib_a-fstatr.o):
In function `_fstat_r':
/home/ops/Desktop/arm-toolchain/newlib/arm-elf/newlib/libc/reent/../../../../newlib-1.18.0/newlib/libc/reent/fstatr.c:62:
undefined reference to `_fstat'
/home/ops/bin/arm-elf/lib/gcc/arm-elf/4.4.3/../../../../arm-elf/lib/libc.a(lib_a-isattyr.o):
In function `_isatty_r':
/home/ops/Desktop/arm-toolchain/newlib/arm-elf/newlib/libc/reent/../../../../newlib-1.18.0/newlib/libc/reent/isattyr.c:58:
undefined reference to `_isatty'


How would I got about resolving this? Should I change the newlib
configuration before I compile and recompile?
I know that I need to add stubs and I've tried adding them from the
codesourcery g++ lite library. However, it gave me many errors about the use
of asm:
syscalls.c:81: error: expected '=', ',', ';', 'asm' or '__attribute__'
before 'asm'

The syscalls I use is similar or the same as the one in:
http://newlib.sourcearchive.com/documentation/1.14.0-1/libgloss_2arm_2syscalls_8c-source.html

I'd be appreciative of any help. Being my first time really compiling gcc
from scratch, I would hope I can make good use of it.
-- 
View this message in context: http://old.nabble.com/GCC-linking-and-compiling-error-for-Cortex-M3-Microcontroller-because-of-Newlib-tp30625742p30625742.html
Sent from the gcc - Help mailing list archive at Nabble.com.



More information about the Gcc-help mailing list