cancel
Showing results for 
Search instead for 
Did you mean: 

"undefined reference to `typeinfo for touchgfx::.." errors with RTTI (run-time type information) enabled

t.decker
Senior II

I'm working on a STM32F7 software project with TouchGFX, FreeRTOS, lwIP and more. Now I'm playing with the "cereal" library for serialization which needs the RTTI option enabled. So I unchecked the -fno_rtti option in the compiler/linker options.

0693W00000NqBthQAF.png 

But this gives me a lot of linker errors for the TouchGFX code:

 

ld.exe: [...] undefined reference to `typeinfo for touchgfx::Application'
ld.exe: [...] undefined reference to `typeinfo for touchgfx::Container'
ld.exe: [...] undefined reference to `typeinfo for touchgfx::Drawable'
ld.exe: [...] undefined reference to `typeinfo for touchgfx::Container'
ld.exe: [...] undefined reference to `typeinfo for touchgfx::Screen'
ld.exe: [...] undefined reference to `typeinfo for touchgfx::TextAreaWithWildcardBase'
ld.exe: [...] undefined reference to `typeinfo for touchgfx::Image'
ld.exe: [...] undefined reference to `typeinfo for touchgfx::Screen'
ld.exe: [...] undefined reference to `typeinfo for touchgfx::DMA_Interface'
ld.exe: [...] undefined reference to `typeinfo for touchgfx::AbstractPartition'
ld.exe: [...] undefined reference to `typeinfo for touchgfx::AbstractPartition'
ld.exe: [...] undefined reference to `typeinfo for touchgfx::AbstractPartition'
ld.exe: [...] undefined reference to `typeinfo for touchgfx::HAL'

After a little "research" I think that I would need a TouchGFX lib also compiled with RTTI enabled. Are there any suggestions on how to solve this?

 

Regards

Tom

When this account seems to be inactive, try @tdecker2 - ST can't change mail addresses, so I had to create a new account.
6 REPLIES 6
Osman SOYKURT
ST Employee

Hello TDeck.1,

RTTI is not compatible with TouchGFX, that's why you have these messages. The  -fno_rtti option must stay checked. I'll ask my colleagues but I don't think we have a solution for that unfortunately. I'll get back to you when I have more infos about it.

/Osman

Osman SOYKURT
ST Software Developer | TouchGFX
GMeur
Senior II

Is there anything new on this issue? Weirdly, IAR compiler just works fine with RTTI activated with the touchgfx library, but not GCC.

You can change compiler settings per source file or source folder. So it might work to enable it globally and keep it disabled for TouchGFX.

Kudo posts if you have the same problem and kudo replies if the solution works.
Click "Accept as Solution" if a reply solved your problem. If no solution was posted please answer with your own.

Yes, I know that, but I need RTTI to work for some touchgfx types (Drawable). I just found out the other day, while moving a project from iar to cubeIDE (which uses gcc) that my dynamic_casts to Drawable cause ld linker to complain. No clue how iar could handle it therefore (and everything just worked as supposed) if Osman just stated that RTTI is not compatible with touchgfx?

Can you share the code that causes problems?

Perhaps you can avoid typecasting or use static casting. Perhaps you can use std::variant.

Kudo posts if you have the same problem and kudo replies if the solution works.
Click "Accept as Solution" if a reply solved your problem. If no solution was posted please answer with your own.

I have a button library written like that, just a simple example with a DButton:

DVirtualButton           touchgfx::Drawable

          |                           |

DAbtsractButton         touchgfx::Widget

          |-----------------------|

       DButton

DButton is both a DVirtualButton and a Drawable. A setup function in a dropDown widget needed to access both DVirtualButton methods (like setOn()) and Drawable methods like setXY(). The setup function was passed a DVirtualButton pointer as argument, which was dynamically casted inside the setup function to a Drawable. I agree it's probably not the best way to do it, but it's an old function, written in c++11 some years ago, when I still didn't understand fully what a dynamic_cast really needed to work out.

I have just quiclkly rewritten the function to avoid using dynamic_cast at all but I'd still be interested to know how to make touchgfx library work with RTTI, and how everything just worked fine with IAR.