Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Can you link Unreal Engine with libraries built with RTTI on Linux?

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?

Product Version: UE 4.21
more ▼

asked Feb 05 '19 at 07:01 PM in Linux

avatar image

1 1 1

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

Unfortunately on Linux mixing RTTI and no-RTTI code is very treacherous, see for example this bug: https://gcc.gnu.org/bugzilla//show_bug.cgi?id=43105 . It is possible to have RTTI enabled in a single module, but then you should be careful to not use engine classes in it - the rest of the (no-RTTI) engine will use that "bridge" to communicate with OpenCV. See OpenEXRWrapper as an example.

more ▼

answered Feb 05 '19 at 08:00 PM

avatar image

2.7k 59 6 88

avatar image mister-liss Feb 05 '19 at 11:10 PM

Thanks. That clarified the problem a bit for me and I was able to resolve it. I was able to modify the plugin's includes to leave out the offending 'typeid()' call that was coming from boost. It seems so simple now but my C++ knowledge is a bit rusty. I largely got distracted by the fact that this works without issue on the Microsoft stack.

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question