Download

[TUTORIAL] How to build the engine from complete scratch

**Disclaimer

This is not an official tutorial. I do not guarantee correctness of the information for all platforms, engine versions and use cases. The purpose of this tutorial is sharing the information about the build system for advanced users rather than solving any particular problem. It is probable that using the engine in a non-standard way will create more issues than it will solve, so follow this tutorial at your own risk and don’t perform these steps on any valuable data. Do not follow any instructions from this tutorial if you do not clearly understand what you are doing and what you are trying to achieve.

And of course I am not liable for any physical, psychical or economical damage(*) caused by proper or improper use of the information presented here.**

Now, if you are still interested lets begin… :slight_smile:

In this tutorial I will describe how to download minimal set of UE4 dependencies and build all binaries from scratch. Why would you want that? No idea :smiley: But I use this workflow to get rid of pre-built binaries for the platforms I do not currently use.

I assume that you are familiar with the engine sources, Visual Studio Command Prompt, MsBuild, UE4 Automation Tool and know how to code in C# (optional).

Okay, lets start with downloading the engine source code from GitHub (by cloning the repo or downloading a zip-archive). After you have downloaded the code you would usually run Setup script to download binary dependencies. You might also run GitDependencies program directly, the program is located at Engine\Binaries\DotNET\GitDependencies.exe and it actually does the job of downloading stuff. I usually run it with a command-line argument: “GitDependencies.exe --all” - this argument tells the program to download all dependencies for all platforms. Of course it will increase download and storage size, so using it isn’t necessary, but I do.

Before you actually run the program, lets see how it knows what files to download. Let’s take a look at the Engine\Build directory. GD scans this folder for any files that match the pattern: “*.gitdeps.xml”. These manifests contain list of files (with their hashes) that will be downloaded by the GD. There are two files that match the pattern:

Commit.gitdeps.xml
Promoted.gitdeps.xml

The first manifest contains list of all engine content files and 3d-party binaries you need to build and use the engine on any platform. The second manifest contains list of pre-built engine binaries and compiled documentation files. It only exists for convenience. To keep GD from downloading pre-built binaries just delete, move or rename Promoted.gitdeps.xml so that it doesn’t match the pattern anymore. Now you can run Setup or GD.

After downloading is finished, take a look inside the Engine\Binaries subfolders. You’ll notice some unusual and sad emptiness there: all engine binaries are missing! However, all 3d-patry files are in place. Your workspace now contains everything necessary to build the engine for any platform (especially if you used --all option :)) and you may back it up if you want. Now it’s time to build the engine and tools!

NOTE: The following steps are only valid for Windows, if you are on another OS use proper build methods for your platform.

The first thing you have to do is to build RPCUtility, both AutomationTool and UnrealBuildTool depend on it and unfortunately they do not build it automatically, so you have to do it manually. Open Visual Studio Command Prompt, go to the engine root directory and run this command:


msbuild Engine\Source\Programs\RPCUtility\RPCUtility.csproj /p:Configuration=Development /p:Platform=AnyCPU

There may be a warning about signing the file: don’t pay attention. Open Engine\Binaries\DotNET: if everything’s right RPCUtility.exe has to be there. Now you can build UBT and Automation Tool.

Using the Automation Tool is the most convenient way to build everything you need. Open the automation script located at Engine\Sources\Programs\AutomationTool\Scripts\BuildCommonTools.Automation.cs. This script is a good starting point: it builds the most essential engine tools. You can just use it as it is or customize it to build whatever engine binaries for whatever platforms you need (here come your C# coding skills :)). You can copy and rename it before editing to avoid future conflicts. After you are ready, go to Engine\Build\BatchFiles and run this command:


RunUAT BuildCommonTools

(Use different name if you renamed the script)

When UAT finishes building your tools you are ready to build the editor in a usual way.

Congratulations! You just built the engine from complete scratch!

(*) or any other kind of damage :stuck_out_tongue:

I saw that building UE in Linux they take many time compiling all resources and i think that UE isn’t well optimized for Linux.