* GCC linking and compiling error for Cortex-M3 Microcontroller because of Newlib
@ 2011-01-09 19:12 deut3892
2011-01-10 13:48 ` Richard Earnshaw
0 siblings, 1 reply; 2+ messages in thread
From: deut3892 @ 2011-01-09 19:12 UTC (permalink / raw)
To: gcc-help
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.
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: GCC linking and compiling error for Cortex-M3 Microcontroller because of Newlib
2011-01-09 19:12 GCC linking and compiling error for Cortex-M3 Microcontroller because of Newlib deut3892
@ 2011-01-10 13:48 ` Richard Earnshaw
0 siblings, 0 replies; 2+ messages in thread
From: Richard Earnshaw @ 2011-01-10 13:48 UTC (permalink / raw)
To: deut3892; +Cc: gcc-help
On Sun, 2011-01-09 at 11:12 -0800, deut3892 wrote:
> 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'
[...]
>
> 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.
newlib is really divided into two parts, the standard C library
implementation and the low-level IO functionality. The symbols you are
missing are all from the latter category. That IO functionality is
normally supplied by libgloss. Perhaps you aren't linking that in
properly.
libgloss cannot be written without some knowledge of how IO works on
your board. If you are doing IO through a serial line then the
implementation is going to be vastly different to a case where IO is
done through some boot monitor program, or when you've got an embedded
file-system. There are some example implementations for ARM boards (for
example, there's an implementation that uses semi-hosting sys-calls that
can be trapped using a JTAG unit), but ultimately you have to decide how
that will be done and link in the relevant version of libgloss.
Hope that helps.
R.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-01-10 13:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-09 19:12 GCC linking and compiling error for Cortex-M3 Microcontroller because of Newlib deut3892
2011-01-10 13:48 ` Richard Earnshaw
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).