How to enable RTTI when compiling a plugin ?

Hello,

I’m trying to link a pretty big library to my plugin and it needs RTTI enabled. After searching in the source code and seeing a variable UseRTTI, I’ve been wondering if there is an option to activate RTTI when compiling the plugin; in the Build.cs file or elsewhere ?
I’ve seen this thread, but I’d like to know if I can activate it for my plugin only, I don’t need RTTI with existing UE4 code.

Thanks in advance

I found the answer, I’ll post it in case someone has a similar problem with BuildTool configuration :

When inheriting from ModuleRules, you gain access to some configuration variables, including bUseRTTI, and others that you can see in the RulesCompiler.cs file (where ModuleRules is declared), in the UnrealBuildTool project.

This doesn’t seem to be used in the mac toolchain though?

Sorry I can’t really help you as I never used UE and a Mac. However, there is a “-fno-rtti”, line 131 of the MacToolChain.cs file.

If it is hardcoded, there is certainly a reason, but you can try editing this line, or other lines, for other options, to suit your needs.

Good luck !

Hey Brice,
Could you share the code where you have used bUseRTTI in the Build.cs file? I’m having the same problem in my project too
Thanks!

Let ExternalLinkTest be the project/plugin to which you want to link some 3rdParty libs which make use of dynamic_cast. Then your C# class in ExternalLinkTest.Build.cs should look somehow like this:

public class ExternalLinkTest : ModuleRules
{
    // ctor
    public ExternalLinkTest(TargetInfo Target)
    {
        bUseRTTI = true; // turn on RTTI

        // ...
    }
}