Duplicate definitions with 3rd party glib

Hi,
I wrote a custom module for a plugin that manages adding my own library based on gstreamer.

In there I am adding simply all static libraries that come with gstreamer and the include paths. I know that these suffice, since I was able to build executables with this FindGSTREAMER.cmake that does the same linking. I link my own lib in the module file at lines 38-39, so these include files are actually included in my plugin’s header files.

The important thing is that gstreamer uses glib-2.0. So when including one of my own include files, which does includes over gstreamer header also some glib header, the symbol GError gets defined. This symbol seems to also be defined within the unreal engine, so I get a duplicate definition. The highlighted one seems to show the location of the unreal definition:

So what is the best way to resolve this? Before rebuilding the unreal engine, I would try to rename GError within glib. But I fear that after resolving that one duplicate definition another will appear, since that isn’t really a solution. Is there a clever way for this within the UE building system?

Update: So I “just” renamed every GError appearence and GThreadPool. I am sry, but please just please uphold to the recommendations and create namespaces… please.

Just in case this is still relevant or someone has the same issue
I think the easiest way to “fix” the issue is to use defines to replace duplicates.
If I remember correclty, this is even done somewhere in the engine before inclufing some SSL headers.

Basically add

#define GError GError_TEMP
#define GThreadPool GThreadPool_TEMP

befoe your third party include.
You can undef them again after the include and use GError_Temp (or whatever you decided to use) in your Code.

Hope this helps someone in the future

Kim

1 Like

You are a gd ninja. Jedi master right here fr fr