problem with Sourcery G++ Lite 2010q1-188 and libnewlib-lpc.a

Started by Taris May 26, 2010
Hello,

I try to use newlib-lpc with Sourcery G++ Lite 2010q1-188 compiler. I can't understand why can I get these errors: undefined reference to `_write', `_close', `_sbrk' and etc. It seems that library "libnewlib-lpc.a" does not provide the system level codes (`_write',`_close' ...)
But I'm sure all these functions are in the libnewlib-lpc.a. Any ideas?

Have you tried newlib-lpc with Sourcery G++ Lite compiler?

Here is my problem:

make all
-------- begin (mode: FLASH_RUN) --------
arm-none-eabi-gcc (Sourcery G++ Lite 2010q1-188) 4.4.1
Copyright (C) 2009 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
**** Linking : FLASH_RUN/test2.elf
arm-none-eabi-gcc -gdwarf-2 -Os -mcpu=arm7tdmi -ffunction-sections -fdata-sections -fpromote-loop-indices -Wall -Wextra -Wimplicit -Wcast-align -Wpointer-arith -Wredundant-decls -Wshadow -Wcast-qual -Wcast-align -Wa,-adhlns=FLASH_RUN/crt0.lst -MD -MP -MF FLASH_RUN/dep/test2.elf.d FLASH_RUN/crt0.o FLASH_RUN/test2.o --output FLASH_RUN/test2.elf -nostdlib -nostartfiles -Wl,-Map=FLASH_RUN/test2.map,--cref,--gc-sections -lc -lnewlib-lpc -lm -lc -lgcc -T./LPC2106-ROM.ld
/home/tomas/CodeSourcery/Sourcery_G++_Lite/bin/../lib/gcc/arm-none-eabi/4.4.1/../../../../arm-none-eabi/lib/libc.a(lib_a-sbrkr.o): In function `_sbrk_r':
sbrkr.c:(.text+0x18): undefined reference to `_sbrk'
/home/tomas/CodeSourcery/Sourcery_G++_Lite/bin/../lib/gcc/arm-none-eabi/4.4.1/../../../../arm-none-eabi/lib/libc.a(lib_a-writer.o): In function `_write_r':
writer.c:(.text+0x20): undefined reference to `_write'
/home/tomas/CodeSourcery/Sourcery_G++_Lite/bin/../lib/gcc/arm-none-eabi/4.4.1/../../../../arm-none-eabi/lib/libc.a(lib_a-closer.o): In function `_close_r':
closer.c:(.text+0x18): undefined reference to `_close'
/home/tomas/CodeSourcery/Sourcery_G++_Lite/bin/../lib/gcc/arm-none-eabi/4.4.1/../../../../arm-none-eabi/lib/libc.a(lib_a-lseekr.o): In function `_lseek_r':
lseekr.c:(.text+0x20): undefined reference to `_lseek'
/home/tomas/CodeSourcery/Sourcery_G++_Lite/bin/../lib/gcc/arm-none-eabi/4.4.1/../../../../arm-none-eabi/lib/libc.a(lib_a-readr.o): In function `_read_r':
readr.c:(.text+0x20): undefined reference to `_read'
/home/tomas/CodeSourcery/Sourcery_G++_Lite/bin/../lib/gcc/arm-none-eabi/4.4.1/../../../../arm-none-eabi/lib/libc.a(lib_a-fstatr.o): In function `_fstat_r':
fstatr.c:(.text+0x1c): undefined reference to `_fstat'
/home/tomas/CodeSourcery/Sourcery_G++_Lite/bin/../lib/gcc/arm-none-eabi/4.4.1/../../../../arm-none-eabi/lib/libc.a(lib_a-isattyr.o): In function `_isatty_r':
isattyr.c:(.text+0x18): undefined reference to `_isatty'
collect2: ld returned 1 exit status
make: *** [FLASH_RUN/test2.elf] Error 1

An Engineer's Guide to the LPC2100 Series

On 26/05/2010 16:34, Taris wrote:
> Hello,
>
> I try to use newlib-lpc with Sourcery G++ Lite 2010q1-188 compiler. I
> can't understand why can I get these errors: undefined reference to
> `_write', `_close', `_sbrk' and etc. It seems that library
> "libnewlib-lpc.a" does not provide the system level codes
> (`_write',`_close' ...) But I'm sure all these functions are in the
> libnewlib-lpc.a. Any ideas?
You would normally provide application specific versions of these
functions yourself. If you don't need the functions then they can be
stubbed out.

Google "newlib sbrk" and you will get a lot of information.

Also, grab the FreeRTOS code and look in the file:
FreeRTOS\Demo\ARM7_LPC2368_Eclipse\RTOSDemo\syscalls.c
for an example of a set of stub functions.
Regards,
Richard.

+ http://www.FreeRTOS.org
Designed for Microcontrollers. More than 7000 downloads per month.

+ http://www.SafeRTOS.com
Certified by T as meeting the requirements for safety related systems.

Maybe the newlib-lpc is providing _close_r and newlib is looking for _close ?
ie. One linked for re-entrancy and the other not.
I'm guessing here !

-----Original Message-----
From: l... [mailto:l...] On Behalf Of Taris
Sent: Thursday, 27 May 2010 1:34 AM
To: l...
Subject: [lpc2000] problem with Sourcery G++ Lite 2010q1-188 and libnewlib-lpc.a

Hello,

I try to use newlib-lpc with Sourcery G++ Lite 2010q1-188 compiler. I can't understand why can I get these errors: undefined reference to `_write', `_close', `_sbrk' and etc. It seems that library "libnewlib-lpc.a" does not provide the system level codes (`_write',`_close' ...)
But I'm sure all these functions are in the libnewlib-lpc.a. Any ideas?

Have you tried newlib-lpc with Sourcery G++ Lite compiler?

Here is my problem:

make all
-------- begin (mode: FLASH_RUN) --------
arm-none-eabi-gcc (Sourcery G++ Lite 2010q1-188) 4.4.1
Copyright (C) 2009 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
**** Linking : FLASH_RUN/test2.elf
arm-none-eabi-gcc -gdwarf-2 -Os -mcpu=arm7tdmi -ffunction-sections -fdata-sections -fpromote-loop-indices -Wall -Wextra -Wimplicit -Wcast-align -Wpointer-arith -Wredundant-decls -Wshadow -Wcast-qual -Wcast-align -Wa,-adhlns=FLASH_RUN/crt0.lst -MD -MP -MF FLASH_RUN/dep/test2.elf.d FLASH_RUN/crt0.o FLASH_RUN/test2.o --output FLASH_RUN/test2.elf -nostdlib -nostartfiles -Wl,-Map=FLASH_RUN/test2.map,--cref,--gc-sections -lc -lnewlib-lpc -lm -lc -lgcc -T./LPC2106-ROM.ld
/home/tomas/CodeSourcery/Sourcery_G++_Lite/bin/../lib/gcc/arm-none-eabi/4.4.1/../../../../arm-none-eabi/lib/libc.a(lib_a-sbrkr.o): In function `_sbrk_r':
sbrkr.c:(.text+0x18): undefined reference to `_sbrk'
/home/tomas/CodeSourcery/Sourcery_G++_Lite/bin/../lib/gcc/arm-none-eabi/4.4.1/../../../../arm-none-eabi/lib/libc.a(lib_a-writer.o): In function `_write_r':
writer.c:(.text+0x20): undefined reference to `_write'
/home/tomas/CodeSourcery/Sourcery_G++_Lite/bin/../lib/gcc/arm-none-eabi/4.4.1/../../../../arm-none-eabi/lib/libc.a(lib_a-closer.o): In function `_close_r':
closer.c:(.text+0x18): undefined reference to `_close'
/home/tomas/CodeSourcery/Sourcery_G++_Lite/bin/../lib/gcc/arm-none-eabi/4.4.1/../../../../arm-none-eabi/lib/libc.a(lib_a-lseekr.o): In function `_lseek_r':
lseekr.c:(.text+0x20): undefined reference to `_lseek'
/home/tomas/CodeSourcery/Sourcery_G++_Lite/bin/../lib/gcc/arm-none-eabi/4.4.1/../../../../arm-none-eabi/lib/libc.a(lib_a-readr.o): In function `_read_r':
readr.c:(.text+0x20): undefined reference to `_read'
/home/tomas/CodeSourcery/Sourcery_G++_Lite/bin/../lib/gcc/arm-none-eabi/4.4.1/../../../../arm-none-eabi/lib/libc.a(lib_a-fstatr.o): In function `_fstat_r':
fstatr.c:(.text+0x1c): undefined reference to `_fstat'
/home/tomas/CodeSourcery/Sourcery_G++_Lite/bin/../lib/gcc/arm-none-eabi/4.4.1/../../../../arm-none-eabi/lib/libc.a(lib_a-isattyr.o): In function `_isatty_r':
isattyr.c:(.text+0x18): undefined reference to `_isatty'
collect2: ld returned 1 exit status
make: *** [FLASH_RUN/test2.elf] Error 1