How can I make Keil RealView ARM MDK (for Cortex-M3) work with BOTH retargeting(to USART) and STL?

2.2k Views Asked by At

I've been searching for a workaround for days. So far no luck.

What I use:

  • STM32F103VET6
  • J-Link
  • RealView MDK-ARM v4.12
  • Both C and C++ code in my program

Before I included STL in my code, everything works fine. I can retarget printf() and scanf() to USART without a problem. This is done by including Retarget.c that came with RV-MDK and writing my own sendchar() and getkey(). Retarget.c has a line that says #pragma import(__use_no_semihosting_swi) which demands the linker to use the retargeting version of <cstdio>, instead invoking the semihosting implementation.

But when I started to #include <deque> and deque<int> buffer;, it doesn't work anymore. It seems that the linker had decided that <deque> depends on the the semihosting <cstdio>, which conflicts with the retargeting code I wrote just now.

What I tried and failed:

  • Get rid of __no_semihosting_swi and instead try to override _sys_open(). It doesn't work because the semihosting <cstdio> depends on an object file which already exports this symbol.
  • Use $super$$ and $sub$$ syntax suggested here (I think I've tried everything they provided!)
  • Use "MicroLIB". It's EPIC FAIL.
  • Digging into the supplied STL headers. I found NO reference to any stdio. And, since I can #include <cstdio> and still have retargeting, I don't think even an reference would make any difference.

I suspect the solution has something to do with directing the linker, but so far I haven't figured out... This is getting so frustrating!

0

There are 0 best solutions below