For a recent project I’ve been working with third-party libraries in UE4 plugins (OpenCV, GDAL, and Boost, among others), and discovered quite a few frustrations when attempting to get everything nicely integrated across Windows, macOS, and Linux. After first writing infrastructure as a CMake “superbuild” project (which worked but was far from ideal), I ended up creating a system based on the Conan package manager that works quite well and alleviates a lot of the headaches that myself and the other devs on my team had been dealing with. Since it works quite nicely for our little team, I though I’d share it with the UE4 community.
The overall workflow looks like this:
I’ve created a Python package called ue4cli that handles querying UBT for build flags related to UE4-bundled libraries (including libc++ under Linux), and a script that generates Conan wrapper packages for those libs so that they can be used as dependencies when building larger libraries (e.g. OpenCV, which depends on zlib and libpng, both of which come bundled with UE4.) By building against the UE4-bundled versions of dependencies, you can avoid clashes between the UE4 versions and external versions (which was one of the major sources of pain for us.) Once these larger packages have been built, C# code in a project or plugin’s [FONT=courier new].Build.cs file can invoke Conan and pass the relevant build flags to the Unreal build system. This makes it easy for the project/plugin to consume prebuilt packages that were in turn compiled specifically to be compatible with UE4.
I’ve written a significantly more detailed document that covers the background, design justifications, and implementation of the system here: http://adamrehn.com/articles/cross-p…real-engine-4/
I’ve also created a demo project with an example of building and using OpenCV: https://github.com/adamrehn/ue4-opencv-demo
Hopefully this workflow can come in handy for other people who also want to integrate functionality from third-party libraries into their UE4 projects!