Improving UE4 in Linux


Due to various reasons, I’ve had to work with Unreal Engine 4.
Since my main development environment is Linux, the quality was amazingly fantastic but there were a few rough edges.

Since Wiki editing is currently disabled, I am posting it here to improve quality of life for Linux devs having the same issues I had after following official instructions and wiki

QtCreator broken autocomplete

The default QMake generator is broken. The CMake generator also contains a few similar bugs, which prevent autocomplete from working.

I’ve submitted a pull request which fixes the QMake generator.
It hasn’t been merged yet, but it’s only a couple lines to change, so you can incorporate it yourself.

The main cause of the problem is that in MyProjectNameDefines.pri

#define DDPI_SHADER_PLATFORM_NAME_MAP { TEXT("XXX"), SP_XXX },

gets converted to:

#define DDPI_SHADER_PLATFORM_NAME_MAP {
#define TEXT(XXX), 1
#define SP_XXX 1
#define }, 1

This causes a disaster in autocomplete. You can fix this by hand in MyProjectNameDefines.pri, but my PR also fixes other minor issues as well.
After this ClangCodeModel is rock solid (although it consumes a lot of RAM and needs a beefy PC).

After you’ve patched UnrealBuildTool with my pull request, you need to generate the project files again:

./GenerateProjectFiles.sh "/home/username/path_to_my_project/MyProjectName.uproject" -game -engine

Sometimes ClangCodeModel will not work at 100% because UE4 uses the override keyword where there is no virtual base function, and ClangCodeModel considers this an error whereas during build it was missed somehow.

You could manually define override and final to nothing in MyProjectNameDefines.pri to workaround this issue.

QtCreator compiler errors do not appear in the Error Console and are not clickable

QtCreator looks in stderr for compiler errors, but UnrealBuildTool.exe dumps compiler errors to stdout.
A simple solution is to redirect everything to stderr:

UE4Editor-Linux 1>&2

How to debug in UE4 Linux?

On Windows, online advice is to run the engine with “-debug” command.
But that doesn’t work on Linux. I’ve scrapped the source code, it’s not there. The debug build is hardcoded to build time options.

You need to build UE4 Editor for Debug support. There are two flavours:

make UE4Editor-Linux-Debug
make UE4Editor-Linux-DebugGame

This is explained in UE4 documentation: Debug is full debug for everything. It’s slow and consumes a lot of RAM. But useful if you’re doing low level work.
DebugGame builds the engine with some optimizations, while your project is built with full debug.

The rest build process is the same as in the official docs.

It is not obviously clear, and you may get a little anxious about rebuilding the source code because it takes an eternity. But yes, you have to do build the engine again even if you want to debug just your project.

Fortunately building UE4Editor-Linux-DebugGame takes much less time than building the normal build (it appears it manages to reuse obj files from the optimized version). But building UE4Editor-Linux-Debug (i.e. the full debug) still takes a lot of time since everything is rebuilt from scratch.

Once you’ve built UE4Editor for Debug/DebugGame, you build your project in exactly the same way:

# The same, but from your /home/username/path_to_my_project/ root
make UE4Editor-Linux-Debug
make UE4Editor-Linux-DebugGame

And you launch it via:

/path/to/ue4/Engine/Binaries/Linux/UE4Editor-Linux-DebugGame /home/username/path_to_my_project/MyProjectName.uproject