Introduction
In March 2015, Epic Games turned its face to the Open Source community, providing free access to its
Unreal Engine version 4 (setting a limit on profits from using the engine at $ 3,000 per quarter). Moreover,
back in 2014, the company said that supporting free operating systems, in particular Linux, is one of its priorities.
It is worth noting that these words did not become a hollow sound, and today the engine works fairly confidently in the Linux environment. There is a sufficient amount of official documentation telling how to install and configure the engine in the environment of this OS.
')
However, with the seeming transparency of the deployment process of the working environment, there are a number of small but unpleasant nuances that make life difficult for penguin fans. Under the cut, a brief and free description of the installation features of the engine that the author encountered, designed to solve some of the difficulties faced by beginners.
1. Baseline
So, we have a computer (CPU: Intel Core i7-2600K, RAM: 16Gb, Video: GeForce 580GTX), with the Arch Linux distribution kit as the operating system.
For this distribution,
there is a package in the user repository
AUR . Judging by the comments to the package, it is going and working, and in principle, you can use it to install the engine. Just wait for the package collector to clone the repository for a long time. With a total size of the release branch of 1.5-2 GB, the cloning process hangs by 81% pulling out about four gigabytes of network. I did not have the patience to wait for the end of this process.
Therefore, we will go the other way, collecting the engine from the source without wrapping it in a package, arguing that the installation of the engine in general is not required. Make sure that the following packages are installed on the system:
- clang - C / C ++ front-end to LLVM compiler
- python - Python interpreter
- qt4 - cross-platform framework for C / C ++ development
- sdl2 - cross-platform library for working with multimedia
- icu is a component of the Unicode libraries for internationalizing applications.
- mono - free implementation of .Net Framework
- xdg-user-dir - "control" user directories such as "Documents", "Images", etc. within the X Window System
- git - client to work with the same version control system
2. Getting the Unreal Engine Source
This
procedure is described in detail
on the Epic Games official website . First you need to have an
Epic Games account , as the source code repository of the engine is private. In addition, you will need to create an account on
Github , for which the above-mentioned office will give access to the repository. Especially there is nothing to comment on: the procedure is quite simple and clear.
Having gained access to the repository, we create in the file system a directory where the engine will be located, go to it and say the spell
$ git clone https://github.com/EpicGames/UnrealEngine.git -b release
and wait for the download branch of the engine. This process takes place in an example faster than when using the Aurov PKGBUILD.
3. Build engine: rake run
After receiving the source code, go to the directory
$ cd UnrealEngine
watching such a picture
$ ls -la
80
drwxr-xr-x 6 maisvendoo users 4096 4 18:02 .
drwxr-xr-x 27 maisvendoo users 4096 5 15:29 ..
-rw-r--r-- 1 maisvendoo users 382 4 17:50 .editorconfig
drwxr-xr-x 11 maisvendoo users 4096 4 17:50 Engine
-rw-r--r-- 1 maisvendoo users 418 4 17:50 GenerateProjectFiles.bat
-rwxr-xr-x 1 maisvendoo users 241 4 17:50 GenerateProjectFiles.command
-rwxr-xr-x 1 maisvendoo users 715 4 17:50 GenerateProjectFiles.sh
drwxr-xr-x 8 maisvendoo users 4096 4 18:01 .git
-rw-r--r-- 1 maisvendoo users 511 4 17:50 .gitattributes
-rw-r--r-- 1 maisvendoo users 3732 4 17:50 .gitignore
-rw-r--r-- 1 maisvendoo users 195 4 17:50 LICENSE.md
-rw-r--r-- 1 maisvendoo users 9472 4 17:50 README.md
drwxr-xr-x 4 maisvendoo users 4096 4 17:50 Samples
-rw-r--r-- 1 maisvendoo users 1304 4 17:50 Setup.bat
-rwxr-xr-x 1 maisvendoo users 208 4 17:50 Setup.command
-rwxr-xr-x 1 maisvendoo users 1345 4 17:50 Setup.sh
drwxr-xr-x 28 maisvendoo users 4096 4 17:50 Templates
-rw-r--r-- 1 maisvendoo users 269 4 17:50 UE4Games.uprojectdir
Assembly instructions are given on the official website in the
documentation as well as
in the official wiki . However, in the case of Arch Linux, you should not rush to follow this instruction, as there is a wary replica on the wiki
If you don’t have to do it
officially suggesting that we use a nasty crutch in the form of an assembly of the debug version of the editor. With this, it is completely forgotten that in addition to the editor, you should build a shader compiler and several other auxiliary utilities included in the engine package. Attempt to build with the parameters proposed by the developer, will be interrupted with the message type
/usr/bin/ld: /mnt/data/install/ue4-test/Engine/Source/ThirdParty/FreeType2/FreeType2-2.6/Lib/Linux/x86_64-unknown-linux-gnu/libfreetype.a(ftlzw.co): relocation R_X86_64_32S against `.text' can not be used when making a shared object; -fPIC
/usr/bin/ld: /mnt/data/install/ue4-test/Engine/Source/ThirdParty/zlib/v1.2.8//lib//Linux/x86_64-unknown-linux-gnu/libz.a(uncompr.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; -fPIC
/usr/bin/ld: final link failed: ,
clang-5.0: error: linker command failed with exit code 1 (use -v to see invocation)
ERROR: UBT ERROR: Failed to produce item: /mnt/data/install/ue4-test/Engine/Binaries/Linux/CrashReportClient
Total build time: 196,17 seconds (Local executor: 0,00 seconds)
make: *** [Makefile:252: CrashReportClient-Linux-Shipping] 5
This problem is known to the unreal-engine Meiteiners of the AUR package, for which they propose to impose a patch fix on the source code. The problem is connected with the change of the gcc and clang build parameters in Arch Linux, which are mentioned
for example here.SSP and PIE are now enabled in gcc (commit) and clang (commit) in the stable repos.
Harrowing holes for binaries built with these compilers.
Found on the arch-dev-public mailing list (subject to "Changing compilation flags").
Enabling Position Independent Executables (PIE) breaks the ABI compatibility for the engine libraries being assembled and leads to the layout errors mentioned above. Accordingly, for normal assembly, you should turn off this option.
To change the settings you need to pick scripts
UBT . The engine uses its build system, the scripts of which are written in C #. Open the
Engine / Source / Programs / UnrealBuildTool / Platform / Linux / LinuxToolChain.cs file by adding the necessary settings to it. To illustrate the changes, I’ll give git diff exhaust
--- a/Engine/Source/Programs/UnrealBuildTool/Platform/Linux/LinuxToolChain.cs
+++ b/Engine/Source/Programs/UnrealBuildTool/Platform/Linux/LinuxToolChain.cs
@@ -377,6 +377,9 @@ namespace UnrealBuildTool
Result += " -Wno-invalid-offsetof";
// we use this feature to allow static FNames.
Result += " -Wno-gnu-string-literal-operator-template";
+// disable unused result's warnings
+Result += " -Wno-unused-result";
The -Wno-unused-result option turns off warnings about unused results returned by functions.
@@ -402,6 +405,7 @@ namespace UnrealBuildTool
Result += " -fno-inline";
Result += " -fno-omit-frame-pointer";
Result += " -fstack-protector";
+ Result += " -fno-pie";
@@ -588,6 +592,8 @@ namespace UnrealBuildTool
Result += " -Wl,--disable-new-dtags";
+ Result += " -nopie";
+ Result += " -Wno-unused-command-line-argument";
With the -fno-pie and -nopie keys we disable PIE for the compiler and linker. The -Wno-unused-command-line-argument switch disables warning about unknown command line parameters.
Before starting the build, create a symlink
$ sudo ln -s /usr/include/locale.h /usr/include/xlocale.h
warning error "xlocale.h is not found".
The described problems are solved in the AUR by imposing a series of patches on the source code, and, in principle, no one forbids the reader to go this way.
After the described preparation, we execute the script
$ ./Setup.sh
The script downloads and collects the necessary third-party libraries. Next, execute the script
$ ./GenerateProjectFiles.sh
activating the Unreal build system, generating files for building projects with make, cmake, qmake, MS Visual Studio, KDevelop and CodeLite. At the end of the script with a clear conscience we give the command
$ make
I note that here you should not use the -j switch that specifies the number of collecting threads. The makefile is generated taking into account the parallelization of the assembly on all threads accessible to your machine.
The build process will take place without errors and will take some time, on my system it is about 40 minutes
[1367/1372] Link libUE4Editor-UE4Game.so
[1368/1372] Link libUE4Editor-Advertising.so
[1369/1372] Link libUE4Editor-BlankModule.so
[1370/1372] Link libUE4Editor-IPC.so
[1371/1372] Link libUE4Editor-BlankPlugin.so
[1372/1372] Link libUE4Editor-XGEController.so
Total build time: 2560,27 seconds (Local executor: 2481,53 seconds)
We also collect the debug version of the engine
$ make DebugSet
4. Create QuickStart in Qt Creator
Launch the UE4 editor compiled by us
$ cd Engine/Binaries/Linux
$ ./UE4Editor
Patiently wait for the shaders to compile (the result of the compilation is cached and the next run will be much faster). At the end of the compilation create a new project in C + +

Select the path where the project is located, give it the name QuickStart and click the green CreateProject button. We are waiting for the editor to generate the project files. At the end of the generation, the editor will close. In Windows, in the presence of MS Visual Studio, this particular IDE will open for you, offering to start coding. In Archa nothing will happen. Therefore, we follow the path that we indicated when creating the project and we looked at what was generated there.
$ ls -l
4728
-rw-r--r-- 1 maisvendoo users 1999696 7 00:06 CMakeLists.txt
drwxr-xr-x 2 maisvendoo users 4096 7 00:05 Config
drwxr-xr-x 2 maisvendoo users 4096 7 00:05 Content
drwxr-xr-x 4 maisvendoo users 4096 7 00:06 Intermediate
-rw-r--r-- 1 maisvendoo users 16777 7 00:05 Makefile
-rw-r--r-- 1 maisvendoo users 350169 7 00:06 QuickStartCodeCompletionFolders.txt
-rw-r--r-- 1 maisvendoo users 14860 7 00:06 QuickStartCodeLitePreProcessor.txt
-rw-r--r-- 1 maisvendoo users 60261 7 00:06 QuickStartConfig.pri
-rw-r--r-- 1 maisvendoo users 22114 7 00:06 QuickStartDefines.pri
-rw-r--r-- 1 maisvendoo users 908626 7 00:06 QuickStartHeader.pri
-rw-r--r-- 1 maisvendoo users 220484 7 00:06 QuickStartIncludes.pri
-rw-r--r-- 1 maisvendoo users 59 7 00:05 QuickStart.kdev4
-rw-r--r-- 1 maisvendoo users 17091 7 00:06 QuickStart.pro
-rw-r--r-- 1 maisvendoo users 722630 7 00:06 QuickStartSource.pri
-rw-r--r-- 1 maisvendoo users 224 7 00:05 QuickStart.uproject
-rw-r--r-- 1 maisvendoo users 462378 7 00:06 QuickStart.workspace
drwxr-xr-x 3 maisvendoo users 4096 7 00:05 Source
Ok, the editor has created the source code (the Source directory) and a number of project files, including the * .pro script for qmake. Launch Qt Creator and open QuickStart.pro in it.

In the window that appears, click "Customize project." Qt Creator configuration is
described in detail
in the official documentation of the engine. I will focus only on some of the settings and give screenshots of their settings
Debug build setup

Setting up the release build

Launch setup

After all the settings are made, press Ctrl + R and start the project. To the question asked to us

We answer in the affirmative. The engine will think a little more, compile the shaders and eventually we get the project, ready to work on the
QuickStart exercise
from the official documentation .

Instead of conclusion
With proper project setup, the next focus is possible. In an open project, click F10

Yeah, the availability of the source code of the engine gives us the opportunity not only to debug the game code, but also to trace the code of the engine itself, which is sometimes required to determine the causes of errors. In this, Epic Games looks much more friendly to its users
than some other offices that also provide their own engine for free.