Downloading and compiling the Unreal Engine source code

As we mentioned in our previous tutorial UE4 can be downloaded in two different versions. The first one and most commonly used is the Launcher or Binary version which we already covered, and the other is the Source version which we will cover in this tutorial.

 


How to download the Source version of Unreal Engine 4


 

The source version of Unreal Engine 4 is located on a website called GitHub a web-based Git or version control repository.

 

hg_tut_03_1

 

Git

Git is a version control system (VCS) for tracking changes in computer files and coordinating work on those files among multiple people. It is primarily used for software development, but it can be used to keep track of changes in any files. As a distributed revision control system it is aimed at speed, data integrity, and support for distributed, non-linear workflows. Git was created by Linus Torvalds in 2005 for development of the Linux kernel, with other kernel developers contributing to its initial development, Its current maintainer since 2005 is Junio Hamano. As of April 2016, GitHub reports having more than 14 million users and more than 35 million repositories, making it the largest host of source code in the world.

 

To download the source version of Unreal Engine 4 go to https://github.com/ and create an account.

 

hg_tut_03_2

 

Once you have created a GitHub account you need to return to your Unreal Engine account at https://www.unrealengine.com/dashboard click on your Profile, there you will see all your information you have entered during your Unreal Engine account creation. On the bottom right you will see a field named GITHUB ACCOUNT NAME. Enter your GitHub account username there, check the “I have read and agree to the End User License Agreement” prompt and click save.

 

hg_tut_03_3

 

Note: You can only link one Unreal Engine account to one GitHub account. You can change the GitHub account associated with your Unreal Engine account if you chose so in the future, but you can not link your GitHub account to two different Unreal Engine accounts.

 

How to fork the Unreal Engine repository

 

After you have successfully linked your Unreal Engine account with your GitHub account, you need to return to GitHub and navigate to the Unreal Engine repository located at https://github.com/EpicGames/UnrealEngine.

 

Caution: Make absolutely sure you have successfully linked your Unreal Engine account with your GitHub account, otherwise you will not be able to see the Unreal Engine repository on GitHub.

 

Once you have reached the repository page click on the Fork button at the top right of the page.

 

hg_tut_03_5

 

A popup will ask you where you want to fork the repository, select your username.

 

hg_tut_03_6

 

After that is complete you need to download and install the GitHub desktop client from https://desktop.github.com/, both Windows and Mac versions are available, Linux is not supported. Linux users must download the latest Git application from https://git-scm.com/downloads. In order to make changes to the source code of Unreal Engine you need to download (clone) the source code you forked earlier to your account. If you made any changes that you feel are noteworthy you can submit a pull request to Epic to integrate them into the editor.

 

Project fork

In software engineering, a project fork happens when developers take a copy of source code from one software package and start independent development on it, creating a distinct and separate piece of software. Free and open-source software is that which, by definition, may be forked from the original development team without prior permission without violating copyright law. However, licensed forks of proprietary software (e.g. Unix) also happen.

 

Pull requests

Contributions to a source code repository that uses a VCS are commonly made by means of a pull request. The contributor requests that the project maintainer “pull” the source code change he made, hence the name “pull request”. The developer creates a pull request to notify maintainers of a new change; a comment thread is associated with each pull request. This allows for focused discussion of code changes. Submitted pull requests are visible to anyone with repository access. A pull request can be accepted or rejected by maintainers. Once the pull request is reviewed and approved, it is merged into the repository.

 

hg_tut_03_7

 

For Windows and Mac users:

 

To download (clone) your forked repository, do the following steps:

 

Start the GitHub client and log in with your credentials and complete the first time setup wizard.

 

 

Once the client is open you will see the following windows, now click on the plus (+) sign on the top left corner of the GitHub client.

 

A pop up menu will appear, click on the Clone tab you should see, your username and underneath the following repositories, EpicGames/Unreal Engine, EpicGames/UnrealTournament and UnrealEngine (with a fork symbol).

 

Click on the last entry UnrealEngine (with a fork symbol) and click on Clone Unreal Engine. Choose a folder where you want to save your Unreal Engine repository and click ok.

 

 

Wait for a while for the download to complete.

 

For Linux users:

 

Set up Git for Linux using this guide.

 

Fork and Clone the Unreal Engine using this guide.

 

Wait for a while for the download to complete.

 


Alternative way of downloading the source code


 

In case you don’t want to use the GitHub client to clone the Unreal Engine repository, you can download the files as a ZIP file. All you have to do is click on the green Clone or Download button on the right side of the Unreal Engine repository page and then click on the Download ZIP button. Select a folder for the file and click OK. Once the download is complete, unzip the file wherever you want and you are ready for the next step.

 

hg_tut_03_15

 


Building Unreal Engine from Source on Windows, Mac and Linux


 

The following steps will guide you through the process of compiling and running Unreal Engine 4 on Windows, Mac and Linux operating systems. The examples used are for Windows 8 and 10, macOS Sierra and the latest version of Ubuntu.

 

For Windows users:

 

If you haven’t already done so, now is the time to install Visual Studio 2013. Although MFC libraries are included in Visual Studio’s default installation settings, make sure that MFC libraries are included for ATL support. You can also use Microsoft’s free version (Visual Studio Community 2017).

 

Once downloading is complete, navigate to the folder you chose to clone your Unreal Engine repository and run the Setup.bat file. This will download around 4GB of files which include all the necessary files needed to compile and run the engine. Time to make a cup of coffee as this might take some time depending on your Internet connection. Subsequent checkouts take less time to download.

 

A warning from SmartScreen may appear in Windows 8 or 10. Click ‘More Info’, then click ‘Run Anyway’ to continue running the Setup batch file.

 

Once the download is complete go to the directory where the Unreal Engine files are located.

 

Inside the root directory, run GenerateProjectFiles.bat to set-up your project files. All project files are intermediate ([UE4Root]\Engine\Intermediate\ProjectFiles). You must generate project files each time you sync a new build to ensure they are up to date. If you delete your Intermediate folder, you must regenerate project files using the ‘GenerateProjectFiles’ batch file.

 

Load the project into Visual Studio by Double-clicking UE4.sln.

 

Set your solution configuration to Development Editor.

 

win-1-configmenu_updated

 

Set your solution platform to Win64.

 

win-2-platform_menu_updated

 

Right-click the UE4 target and select Build.

 

win-3-buildue4

 

Running the Editor

 

Set your startup project to UE4.

 

win-4-setue4_startprj

 

Right-click the UE4 project, hover over ‘Debug’ and click ‘Start New Instance’ to launch the editor.

 

win-5-runcompiledwindowseditor

 

Alternatively, you can press the F5 key on your keyboard to start a new instance of the editor.

 

Congratulations! You’ve compiled and launched the engine from source.

 

win-6-compilededitor_windows

 

For Mac users:

 

If you haven’t already done so, now is the time to install the latest version of Xcode.

 

Once downloading is complete, navigate to the folder you chose to clone your Unreal Engine repository and run the Setup.command file. This will download around 4GB of files which include all the necessary files needed to compile and run the engine. Subsequent checkouts take less time to download. Once the download is complete close the Terminal window that has opened.

 

Inside the root directory, run GenerateProjectFiles.command to set-up your project files.

 

Load the project into XCode by Double-clicking UE4.xcodeproj.

 

To set your build target, select UE4Editor – Mac for My Mac in the title bar.

 

mac-1-settingmactarget

 

To build the project, select Product > Build.

 

mac-2-buildingmaceditor

 

Running the Editor

 

Select Product > Run to launch the editor.

 

mac-3-runningmaceditor

Congratulations! You’ve compiled and launched the engine from source.

 

mac-4-compilededitor_mac

 

For Linux Users:

 

Inside the root folder, run Setup.sh from the terminal to download the engine’s binary content.

 

runsetupshellscript_linux

 

This will download around 4GB of files which include all the necessary files needed to compile and run the engine. Time to make a cup of coffee as this might take some time depending on your Internet connection. Subsequent checkouts take less time to download.

 

If you don’t see a **SUCCESS** message after running this step, refer to the ‘BuildThirdParty.log’ file for more information. ‘BuildThirdParty.log’ is located in the [UE4Root]/Engine/Build/BatchFiles/Linux directory.

 

Please make sure your system has at least ten (10) gigabytes of disk space before performing the following steps.

 

Inside the root directory, run Setup.sh from the terminal to setup the files needed to generate the project files.

 

linux-1-runsetupshellscript_linux

 

Now, run GenerateProjectFiles.sh from the terminal to generate your project files.

 

linux-2-rungenprjfilesshellscript_linux

To build the project, run make from the terminal.

 

linux-3-runmakefile_linux

 

Depending on your system’s specifications, it may take anywhere from ten minutes to over an hour to compile the engine. If you want to shorten the time it takes to compile the engine from source, we recommend compiling the source code on a machine that has at least eight (8) gigabytes of RAM with a multi-core processor having at least eight (8) cores (including hyperthreading).

 

Running the Editor

 

If you’re unable to create an OpenGL context as you’re working through these steps, you may need to update your graphics drivers (refer to Unreal Engine’s documentation on Supported Graphics Drivers ).

 

Navigate to the editor’s binary path by entering cd Engine/Binaries/Linux/ into the terminal.

 

Run UE4Editor to launch the editor.

 

linux-4-runue4editor_linux

 

Congratulations! You’ve compiled and launched the engine from source.

 

linux-5-compilededitor_linux

 

Now that we have both versions of Unreal Engine 4 up and running on our machines it is time for a break. On our next post we will download some of the free content available on the Unreal Marketplace, create our first project and start getting familiar with the Unreal Engine Editor.

 

If you want to buy us a beer and see your name entered in the Backers Hall of Fame you can do so by visiting our Patreon page. Thank you.

 

Sources, inspirations and interesting reads:

Wikipedia,

Unreal Engine 4 Documentation.

 

Next tutorial: Getting to know the Unreal Editor.