38. How to easily compile your Plugin with UE – EasyKafka example

This is a short post on how to compile your plugin code against another version of Unreal Engine.

At times, when you upgrade your UE version, you may find that your plugins are no longer compatible because of the version of UE they’ve been built with. Often, the code itself will be compatible (not always though!) and all you need to do is just compile it using the Engine version that you have.

There was some very useful information already available, so I will not re-make the same videos but summarize steps here.

The steps can be found in this video:

You may also need to make sure that you have all the pre-requisites, which were discussed in this video:

Getting started

In order to get started, you will need to get to the plugin source code. This can usually be found in the description of the plugin.

In my case, I found a repository just using Google: sha3sha3/UE-EasyKafka.

Download the plugin code.

Plugin code downloaded

Next open your CMD and navigate to your UE directory, specifically to \Engine\Build\BatchFiles.

My full path looks like so: G:\Unreal\UE_5.1\Engine\Build\BatchFiles

The path for my plugin is: G:\libraries\UE-EasyKafka-master\UE-EasyKafka-master (as partially visible from screenshot above).

Here I want to execute a batch file to compile the plugin using this version of the UE.

The full command looks like so:

G:\Unreal\UE_5.1\Engine\Build\BatchFiles> RunUAT.bat BuildPlugin -plugin="G:\libraries\UE-EasyKafka-master\UE-EasyKafka-master\EasyKafka.uplugin" -package="G:\libraries\UE-EasyKafka-master\UE-EasyKafka-master\EasyKafka501"

Let’s see what its doing:

  • executing RunUAT.bat
  • Telling the batch file to execute this function: BuildPlugin
  • Specifying location for the plugin: -plugin=
  • Specifying where the result will go: -package=

Based on the above, I should find my result be in ‘EasyKafka501‘ folder.

Compiled result

Build of the plugin and result

From the screenshot above, I can see the folder was generated, but the build showed up as not succesful!

I’m not an expert in this field so I am not entirely sure which part has failed, but if you check in the generated folder, you will find that it will have a sample project created and it will contain a Plugins folder – this is the key – if it’s not generated, something failed badly, but if you have this folder, don’t worry about the build failed message, as you’ve got what you needed!

I’ve tested with 3-4 plugins and 2 succeeded and 2 did not, but at all times I got the required compiled plugin which was working.

Find the compiled plugin

Now you need to copy/move this folder into your Engine plugins folder to make it available

After copying it across, notice that it becomes available to use!

For most plugins that’s it, you’re ready, just enable the plugin and restart!

Easy Kafka Plugin specific steps

This will be used alongside Kafka setup in this post: How to connect to Kafka with Springboot/Micronaut + Docker (unreal-mmo-dev.com)

After enabling the plugin there was some issues:

Checking the logs in your UE project folder, I found:

[2023.04.05-09.42.48:186][  0]LogWindows: Failed to preload 'G:/Unreal/UE_5.1/Engine/Plugins/EasyKafka/Binaries/Win64/UnrealEditor-KafkaConsumer.dll' (GetLastError=126)
[2023.04.05-09.42.48:186][  0]LogWindows:   Missing import: rdkafka.dll
[2023.04.05-09.42.48:186][  0]LogWindows:   Looked in: ../../../Engine/Binaries/Win64
[2023.04.05-09.42.48:186][  0]LogWindows:   Looked in: ../../../../../MyMmoRpg/Binaries/Win64
[2023.04.05-09.42.48:186][  0]LogWindows:   Looked in: G:\MyMmoRpg\Binaries\Win64
......

I searched the plugin folder and found the relevant DLLs in:

G:\Unreal\UE_5.1\Engine\Plugins\EasyKafka\Source\ThirdParty\KafkaLib\bin\Win64

As a temporary measure, I copied those DLLs into my project binaries: <project_dir>\Binaries\Win64 (check the logs where it tried to search).

Note that in future versions this may be fixed and this may not be required.

I raised the issue here: Installation issue – Win64 · Issue #2 · sha3sha3/UE-EasyKafka (github.com) so perhaps it will be updated in that thread when its resolved.

Working example

There were a couple of other issues with silent failures and crashes (crash occurs occasionally on flush command which perhaps doesn’t have timeout).

Also it currently crashes if you don’t provide credentials (so I assume it only works on Kafka with authentication, which is fairly standard practice so is ok).

Having said that, I got a working example working with the following blueprints.

Easy Kafka working blueprints

The bind event on message produced is optional, but can be useful for debugging etc.

Note that the configuration part is important, there are multiple overrides for the Create Producer function, but only this one worked where I specified the security pieces:

Kafka configuration

These configs should match your server configuration, see the post where I’ve configured my Kafka service in docker-compose and java.

Finally, make sure you connect it to ‘begin play’ functionality.

Connect functionality to begin play

Note that I added this logic to my actor blueprint, it can live almost anywhere depending on your requirements.

Testing

I added a callback in the blueprints which printed to screen the topic name of where I published. Therefore after I start the game, I can see its starting to populate.

Also from my server I am able to capture those events: