Showing results for 
Search instead for 
Did you mean: 

Can't seem to get Shawn Hymel's custom "printf" library working on my C++ project

Associate II

Hi everyone,

I have a noob question regarding using "printf" on STM32F4 boards. I found a library made by Shawn Hymel which will let me use the function "printf" to the serial port:

The error I'm getting is shown in the attached image named "stm32_error". The image "stm32_structure" shows how I successfully excluded "syscalls.c" like the tutorial suggested. I'm also uploading the main CPP file for my project, in case I missed any errors there.

The library seems really convenient, but it is based off <stdio.h>, and I'm using C++. I think there shouldn't be a problem, since a few forum posts I've found stated that <stdio.h> is backwards compatible with C++. I still can't explain the error though.

Anyway, thank you for your support.


The error says RetargetInit is not defined. Do you define it somewhere? If it's in a C++ file, you'll need to declare it as extern "C".

extern "C" {
void RetargetInit(...) {

If you feel a post has answered your question, please click "Accept as Solution".