Keil™, An ARM® Company

Technical Support

GCC: USING PRINTF WITH GNU


Information in this article applies to:

  • GNU C Compiler for ARM Version 3.22

QUESTION

I have problems when linking C code that contains calls to standard library functions like printf. My target is Keil MCB2100 with Philips LPC2129 CPU and I am using the GNU C Compiler that was included with this Board.

When I link my application I get the message listed below:

linking...
main.o(.text+0x18): In function 'main':
main.c(8): error: undefined reference to 'printf'
collect2: ld returned 1 exit status

ANSWER

You need to configure the GNU Run-time system. A good example that shows this is in the folder Keil\ARM\GNU\Examples\Measure. Take a look at the dialog Project — Options — Linker. It is important that you add standard run-time libraries and that you re-target the low-level output routines with similar functions as shown in the files SYSCALLS.C and SERIAL.C.

As an alternative, you may download the current revision of the Keil ARM tools and use the Keil CARM Compiler. The run-time system of this compiler is designed for embedded systems and will work instantly with the MCB2100 Board.

MORE INFORMATION

  • Getting Started for ARM User's Guide (GSA.CHM)

SEE ALSO

Last Reviewed: Tuesday, January 16, 2007


Did this article provide the answer you needed?
 
Yes
No
Not Sure