Unreal Engine has a plugin for integrating with OpenCV. Currently that plugin works on Windows. I’m trying to modify this plugin to work on Linux. I’ve worked through many issues but I have one I can’t resolve.
When I try to build the plugin without modification, I get an error ‘cannot use typeid with -fno-rtti’. The error is from a file ‘any.h’ which is a part of the OpenCV FLANN feature set and appears to have been copied over from boost. To address this, I enable RTTI for the module of the plugin I’m building. Unfortunately, this leads to load time errors like the following.
‘dlopen failed: /home/lvl-dev/Projects/TestOpenCVModules/Plugins/OpenCVLensDistortion/Binaries/Linux/libUE4Editor-OpenCVLensCalibration.so: undefined symbol: _ZTI7UObject ModuleManager: Unable to load module ‘/home/lvl-dev/Projects/TestOpenCVModules/Plugins/OpenCVLensDistortion/Binaries/Linux/libUE4Editor-OpenCVLensCalibration.so’ because the file couldn’t be loaded by the OS.’
As far as I can tell, this is because Unreal builds by default with ‘-fno-rtti’. And now the Unreal objects in my plugin expect RTTI information to be available for the Unreal objects when my libraries are loaded at runtime. I found you can pass ‘RTLD_LAZY’ to’dlopen()’ which I thought would address this but this flag is already being passed when my shared object is loaded.
The next obvious thing is to just build everything with RTTI but I’ve been unable to accomplish this. I’ve seen on some forums that building Unreal with RTTI is possible after version 4.15 or so. However, when I’ve tried to build the engine with RTTI I get errors from attempting to link compiled third party dependencies that are now incompatible with Unreal (WebRTC for example). I’d really rather not work my way through building every Unreal dependency from source myself.
Strangely nothing is done to handle this issue on Windows. It seems the Microsoft linker and runtime handles both RTTI and non-RTTI definitions of the object without issue.
Is there a straight forward way to build and successfully run wtih C++ RTTI enabled?
Is there a way to mix RTTI and non-RTTI objects, as Microsoft seems to do, and suppress the link errors from the runtime?
Is there some solution I’m not considering?