ARM Technical Support Knowledge Articles

USING PRINTF WITH GNU

Applies to: GNU C Compiler for ARM

Answer


Information in this article applies to:


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 KeilARMGNUExamplesMeasure. 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

SEE ALSO

Article last edited on: 2007-01-16 14:29:43

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential