sprintf works with LPC1343 but cause compile failure with LPC1345

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

sprintf works with LPC1343 but cause compile failure with LPC1345

905 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CC58 on Wed Jan 23 16:52:37 MST 2013
Below sprintf works in LPCexpresso project for LPC1343, but gets below compile error in LPC1345 project.
I assume it related to the differing libs each processor uses.
(I'm using  LPCXpresso v4.2.0, but just tried v5.0.12 and it fails too)
Is there a fix for this?

#include <stdio.h>

sprintf((char *)(test)," %d \r\n", len);


compile error:

Invoking: MCU Linker
arm-none-eabi-gcc -nostdlib -L"C:\Users\cc\LPC_tempster1345\CMSISv2p10_LPC13Uxx\Debug" -L"C:\Users\cc\LPC_tempster1345\LPC13Uxx_DriverLib\Debug" -Xlinker -Map="ROM_USB_msc.map" -Xlinker --gc-sections -mcpu=cortex-m3 -mthumb -T "ROM_USB_msc_Debug.ld" -o"ROM_USB_msc.axf"  ./src/DiskImg.o ./src/cr_startup_lpc13u.o ./src/lpc13uxx_usbd_msc_mem.o ./src/main.o ./src/mem_lpc13uxx_usbdesc.o   -lCMSISv2p10_LPC13Uxx -lLPC13Uxx_DriverLib
c:/nxp/lpcxpresso_4.2.0_264/lpcxpresso/tools/bin/../lib/gcc/arm-none-eabi/4.5.1/../../../../arm-none-eabi/lib/thumb2\libcr_c.a(_deferredlazyseek.o): In function `__flsbuf':
_deferredlazyseek.c:(.text.(float, long, short, bool, float __restrict)+0x96): undefined reference to `__sys_istty'
c:/nxp/lpcxpresso_4.2.0_264/lpcxpresso/tools/bin/../lib/gcc/arm-none-eabi/4.5.1/../../../../arm-none-eabi/lib/thumb2\libcr_c.a(_writebuf.o): In function `_Cwritebuf':
_writebuf.c:(.text._Cwritebuf+0x18): undefined reference to `__sys_flen'
_writebuf.c:(.text._Cwritebuf+0x2e): undefined reference to `__sys_seek'
_writebuf.c:(.text._Cwritebuf+0x56): undefined reference to `__sys_write'
c:/nxp/lpcxpresso_4.2.0_264/lpcxpresso/tools/bin/../lib/gcc/arm-none-eabi/4.5.1/../../../../arm-none-eabi/lib/thumb2\libcr_c.a(alloc.o): In function `malloc':
alloc.c:(.text.malloc+0x78): undefined reference to `_sbrk'
alloc.c:(.text.malloc+0x9c): undefined reference to `_sbrk'
c:/nxp/lpcxpresso_4.2.0_264/lpcxpresso/tools/bin/../lib/gcc/arm-none-eabi/4.5.1/../../../../arm-none-eabi/lib/thumb2\libcr_c.a(alloc.o): In function `_Csys_alloc':
alloc.c:(.text._Csys_alloc+0xe): undefined reference to `__sys_write'
alloc.c:(.text._Csys_alloc+0x12): undefined reference to `__sys_appexit'
c:/nxp/lpcxpresso_4.2.0_264/lpcxpresso/tools/bin/../lib/gcc/arm-none-eabi/4.5.1/../../../../arm-none-eabi/lib/thumb2\libcr_c.a(fseek.o): In function `fseek':
fseek.c:(.text.fseek+0x1c): undefined reference to `__sys_istty'
fseek.c:(.text.fseek+0x3e): undefined reference to `__sys_flen'
collect2: ld returned 1 exit status
make: *** [ROM_USB_msc.axf] Error 1
Labels (1)
0 Kudos
2 Replies

772 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CC58 on Thu Jan 24 07:58:33 MST 2013
Thanks for quick response and info I needed. 

Change of MCU Linker from Redlib(none) to Redlib(semihost)
allowed clean compile using sprintf.

0 Kudos

772 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Wouter on Thu Jan 24 04:22:49 MST 2013
Hi,

You are not linking against the right C library. for sprintf you'll need atleast the nohost variant(and for semihosting the semihost variant). See:
http://support.code-red-tech.com/CodeRedWiki/LibraryVariants
and
http://support.code-red-tech.com/CodeRedWiki/SwitchingCLibrary

Regards,
Wouter
0 Kudos