4
\$\begingroup\$

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 this 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 when I looked at the source it was already using it.

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?

\$\endgroup\$
0
\$\begingroup\$

I wasn't able to mix the RTTI and non-RTTI definitions but I was able to get Unreal to work with OpenCV on Linux. I did this by disabling the FLANN features. This can be done via a cmake switch. Disabling this no longer triggered the #include path that was pulling in the call to RTTI related features. Thus I was able to build my Unreal module without RTTI.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.