Undefined references with stdlib with all library types

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

Undefined references with stdlib with all library types

2,701 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by jdebliek on Fri Jul 04 09:55:41 MST 2014
I am getting a number of undefined references when compiling a project.  I have tried the nohost and semihost redlib libraries and even newlib, but I get the following reference errors:

c:/nxp/lpcxpresso_6.1.0_164/lpcxpresso/tools/bin/../lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/lib/armv7-m\libcr_c.a(alloc.o): In function `malloc':
alloc.c:(.text.malloc+0x70): undefined reference to `_sbrk'
alloc.c:(.text.malloc+0x90): undefined reference to `_sbrk'
c:/nxp/lpcxpresso_6.1.0_164/lpcxpresso/tools/bin/../lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/lib/armv7-m\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_6.1.0_164/lpcxpresso/tools/bin/../lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/lib/armv7-m\libcr_c.a(cr_clock.o): In function `clock':
cr_clock.c:(.text.clock+0x0): undefined reference to `__sys_clock'
c:/nxp/lpcxpresso_6.1.0_164/lpcxpresso/tools/bin/../lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/lib/armv7-m\libcr_c.a(_deferredlazyseek.o): In function `__flsbuf':
_deferredlazyseek.c:(.text.(float, long, short, bool, float __restrict)+0x8a): undefined reference to `__sys_istty'
c:/nxp/lpcxpresso_6.1.0_164/lpcxpresso/tools/bin/../lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/lib/armv7-m\libcr_c.a(_writebuf.o): In function `_Cwritebuf':
_writebuf.c:(.text._Cwritebuf+0x16): undefined reference to `__sys_flen'
_writebuf.c:(.text._Cwritebuf+0x2a): undefined reference to `__sys_seek'
_writebuf.c:(.text._Cwritebuf+0x52): undefined reference to `__sys_write'
c:/nxp/lpcxpresso_6.1.0_164/lpcxpresso/tools/bin/../lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/lib/armv7-m\libcr_c.a(fseek.o): In function `fseek':
fseek.c:(.text.fseek+0x1a): undefined reference to `__sys_istty'
fseek.c:(.text.fseek+0x3c): undefined reference to `__sys_flen'

If I disable the "no startup or default libs" linker option, I get fewer undefined references, but there are still two remaining:

c:/nxp/lpcxpresso_6.1.0_164/lpcxpresso/tools/bin/../lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/lib/armv7-m\libc.a(lib_a-sbrkr.o): In function `_sbrk_r':
sbrkr.c:(.text._sbrk_r+0xc): undefined reference to `_sbrk'
c:/nxp/lpcxpresso_6.1.0_164/lpcxpresso/tools/bin/../lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/lib/armv7-m\libc.a(lib_a-timesr.o): In function `_times_r':
timesr.c:(.text._times_r+0x2): undefined reference to `_times'

I am not sure what else to try.  Any help would be appreciated.
0 Kudos
Reply
3 Replies

2,205 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by jdebliek on Mon Jul 07 13:04:08 MST 2014
When I first encountered the problem, I tried adding "#include <stdlib.h>" to the module using malloc.  I had left that in when I tried switching to the semihost library.  It turns out that when I remove the stdlib include and use the semihost library, it now builds properly.
0 Kudos
Reply

2,205 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by lpcxpresso-support on Fri Jul 04 10:20:30 MST 2014
Even better, read the FAQ.
http://www.lpcware.com/content/faq/lpcxpresso/linker-undefined-reference

labrat:
upgrading just to try to fix this won't help, it is a project configuration problem, as explained in the FAQ.
0 Kudos
Reply

2,205 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by LabRat on Fri Jul 04 10:09:50 MST 2014

Quote: jdebliek
I am not sure what else to try.



Update to 7.2  :quest:
0 Kudos
Reply