Kindergarten printf question

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

Kindergarten printf question

940 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by hass on Tue May 01 05:48:08 MST 2012
After exercising demo programs (blinky etc) and creating a few simple projects, I lifted an example from the forum which happens to use printf.  It fails to link unless I comment out the printf statements. Upon discovering this, I inserted a printf into  "LPC1343_cmsis2_blinky" and witnessed the same failure. The only clues I am aware of  ( as a Rookie)  are a series of undefined references  being called out by the linker. Here's an example

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'

I'll appreciate any help on this seemingly trivial problem.
0 Kudos
Reply
5 Replies

916 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CodeRedSupport on Thu May 03 07:09:40 MST 2012
Glad to hear you solved your problem. But it sounds like you missed the easy way to switch an existing project to use the semihosted variant of the C library....
[FONT=Courier New][SIZE=2]
Quickstart -> Quick Settings -> Set library type[/SIZE][/FONT]

which is at the top of the FAQ at:

http://support.code-red-tech.com/CodeRedWiki/SwitchingCLibrary

I've tweaked the FAQ to make this shortcut more obvious.

Regards,
CodeRedSupport.
0 Kudos
Reply

916 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by hass on Thu May 03 06:35:23 MST 2012
Thanks to all for your help. The magic solution was to have project defined as
RedLib (Semi Hosting).  It's an option you can specify when using project wizard. In my case, I had to modify project options by following a rather  convoluted series of steps outlined in the Code Red forum link as provided by ZERO.
0 Kudos
Reply

916 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by researchinnovation on Wed May 02 04:09:29 MST 2012
@Hass....Hi...!!

Try with the following link and please add the required header file,like #include<stdio.h> and #include<stdlib.h>

http://www.cplusplus.com/reference/clibrary/cstdio/fprintf/

Hope this helps you.


Thanks & Regards..:)
0 Kudos
Reply

916 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by hass on Tue May 01 06:19:46 MST 2012
Thank you for your guidance. I had searched  Code Red and NXP wiki/forums  without success before posting. The magic words seem to be "Undefined reference" which of course I did not include. Sorry to bother you all with this, but after spending a half day spinning my wheels, it was time to do something.
Thanks again
0 Kudos
Reply

916 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Tue May 01 05:58:36 MST 2012

Quote: hass
I'll appreciate any help on this seemingly trivial problem.



A lot of this problems are already described in CodeRedWiki :)

Your problem: http://support.code-red-tech.com/CodeRedWiki/UndefinedReference?highlight=%28sys\_write%29
0 Kudos
Reply