cancel
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

MGall.6
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:

https://shawnhymel.com/1873/how-to-use-printf-on-stm32/?unapproved=6345&moderation-hash=9b190082e103e0e2e8d26b571f54d5c8#comment-6345

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.

1 REPLY 1
TDK
Guru

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