cesium-unreal
cesium-unreal copied to clipboard
Crash on package when using Cesium for Unreal and nDisplay Plugin
User on the forum reports that they are unable to package their Unreal app when they are using both Cesium for Unreal and Unreal's nDisplay plugin. It seems like this is because both Cesium for Unreal and nDisplay import tinyxml2.lib, which causes it to crash.
LNK2005 : “protected: __cdecl tinyxml2::XMLComment::XMLComment(class tinyxml2::XMLDocument *)” (??0XMLComment@tinyxml2@@IEAA@PEAVXMLDocument@1@@Z) already defined in tinyxml2.lib(tinyxml2.obj)"
Is there a way to include compatibility for situations like this? Can we check to see if it's already imported before importing it ourselves, or something?
This is especially tricky because tinyxml2 isn't a "real" third party dependency of Unreal Engine, but rather a private dependency of nDisplay, found in its own directory. When Cesium for Unreal and nDisplay are built into the same executable or DLL/SO, as they are in packaged builds (but not in regular development or debug builds), this presents a problem because each tries to link in its own copy of tinyxml2.lib. Some options, none of which are really any good:
- Rename all the tinyxml2 symbols in the version we use in cesium-native, so we can have our own private copy of it. Arguably we should do this with all third-party libraries, because we have no way of knowing what other plugins now, in the future, or from the marketplace (or even an end-user's project!) will use the same libraries we use.
- It might be possible to tell UBT to always put our plugin in its own DLL/SO. Maybe. And I'm not sure of the implications.
- Make sure cesium-native uses nDisplay's version of tinyxml2. Conan provides a halfway-decent way of achieving this, if we can ever get cesium-unreal building with Conan. But this is really only viable for sharing dependencies with plugins included in Unreal Engine by default. And woe if we ever find two plugins using different versions of the same third-party library (but in this case it would already be impossible to use them together, so hopefully Epic takes pains to avoid it).
User who initially spotted the issue created a UDN post for it, and it sounds like the library will be moved to Engine/Source/ThirdParty so that plugins can share it. This is planned for UE 5.1.
Do we know if this has been solved in 5.1? I'm having the same issue now...
Unfortunately I still see this issue after upgrading to UE 5.1. Really interested in a solution or work around!
One article I came across seems to have fixed this problem
Just comment out the tinyxml2 from CesiumRuntime.Build.cs file and restart then it should work