Compiling Unreal Engine 4 from source on Windows and Linux
May 2, 2019
Compiling Unreal from source is far easier than people may think. I will be showing you how to compile from source on both Windows and Ubuntu, although it should work on any Linux OS. The process is nearly identical on both systems.
We will be compiling Unreal Engine 4.22 which is, at the time of writing this, the latest version of Unreal and the first to include Ray Tracing support.
If you haven't already you will need to sign up for a GitHub account and link your account to your Epic Games account. Follow the instructions on this page to do it: https://www.unrealengine.com/en-US/ue4-on-github
Unreal Engine Website
Windows
Before we begin, make sure to have installed Visual Studio 2017 or 2019 with the tools needed to compile C++ code. Since you're reading this I assume you've already VS installed with the necessary tools.
1 - Now you've got your Epic Games and GitHub accounts connected, clone the engine into a folder of your choosing by opening a Git terminal and typing:
sh
1git clone https://github.com/EpicGames/UnrealEngine.git --branch 4.22
The output after cloning
4 - Open the UE4 solution file in Visual Studio. Then, all you need to do is click on the UE4 project and then click Run. It will take a few hours to compile, after which the Editor will launch automatically.
Linux
1 - After you have connected your Epic Games and GitHub accounts, open your terminal and type:
sh
1git clone https://github.com/EpicGames/UnrealEngine.git --branch 4.22
sh
1cd UnrealEngine
3 - Then prepare Unreal to be built using Setup.sh which will download, update and install any needed dependencies. This could take a while.
sh
1./Setup.sh
During this process you'll see a box asking to register Unreal Engine file types. You want to select "Yes". Once its complete you should see a Success message.
4 - Next you need to run:
sh
1./GenerateProjectFiles.sh
This will generate the project files needed to compile the engine and shouldn't take too long.
5 - And now for the last part, run:
sh
1make
This will take a while from a couple of hours to a few depending on your system specs so go make a cup of tea and watch a movie. Once that's complete you're ready to run the Editor. Just type:
sh
1./Engine/Binaries/Linux/UE4Editor
Unreal now also defaults to use Vulkan as of 4.21 which may not work on older systems.
If you're getting any errors about Vulkan such as "Cannot find a compatible Vulkan device or driver." just add -opengl4 as a launch parameter like so:
sh
1./Engine/Binaries/Linux/UE4Editor -opengl4
I have another guide here that goes through overriding Unreal to default back to opengl4 rather than Vulkan. You can read that here:
https://rhyce.dev/blog/enable-opengl-and-disable-vulkan-in-unreal-engine-4-25/
It'll also be added to your application menu for easier access but I prefer to run it from the command line to see what the engine is actually doing.
The first launch will take a while as the engine verifies and compiles needed shaders. It only has to do this once so future launches will be much quicker.
Congratulations! You've now built Unreal Engine from source!
What I would suggest doing now is going over to my other post on "Improving UE4 Shader Compile Times" for a guide to help speed up the shader compile times. This requires a source built version of the engine so, why not?
If this helped you, please consider supporting me by buying me a coffee at https://ko-fi.com/rhyce