Cross-Compiling for Linux

LinuxXC_Banner.png

Recent improvements to the cross-compile toolchain make it possible for Unreal Engine 4 (UE4) developers to target a variety of platforms from their Windows development environment. This guide tells you which platforms you can target with the cross-compilation toolchain, providing a link to download the toolchain, and ultimately showing you how to set it up to cross-compile a UE4 project for Linux.

If you're developing your project with Unreal Engine, version 4.13 (or older), you'll want to refer to our Cross-Compiling for Linux (Legacy)NEW! documentation.

Targeted Platforms

With the release of Unreal Engine, version 4.15, developers can target the following platforms with the toolchain:

Architecture Sub-Architecture Vendor System Application Binary Interface (abi)
AArch64 N/A Unknown Linux gnueabi
ARM N/A Unknown Linux gnueabihf
i686 N/A Unknown Linux gnu
x86_64 N/A Unknown Linux gnu

Setting up the Toolchain

If you want to set up a toolchain from your Windows (host) computer to target any of the aforementioned platforms, you'll have to download the toolchain and set your system's environment variable to package your application for Linux and ARM based environments. If this is your first time packaging UE4 projects for the Linux platform, you'll also have to build the engine in Visual Studio for Linux. After working through the following steps, your host environment will be set up to target any of the currently supported platforms.

Please make sure that you have a reliable Internet connection prior to following these steps. Depending on the speed of your Internet connection, downloading the toolchain can take anywhere from a few minutes to a few hours.

Downloading the Toolchain

  1. Click the link to download our Clang 3.9.0 based toolchain.

  2. Now, create a new folder, naming it Linux_CrossCompileToolChain.

    Click for full image.

    If you're using a different naming convention, substitute your preferred folder name with the one we've chosen for illustrative purposes.

  3. Extract the toolchain, being sure to set the extracted file's destination to the folder that you created in the previous step.

    LinuxXC_Step3.png

    Click for full image.

  4. Open the [ROOT]/Linux_CrossCompileToolChain/v8_clang-3.9.0-centos7 folder to view the extracted files.

    Click for full image.

Setting the Environment Variable

  1. Prior to setting the LINUX_MULTIARCH_ROOT environment variable, double-click the Setup batch file (Setup.bat) to output the appropriate environment variable settings for your computer.

    Click for full image.

  2. At this point, a new OutputEnvVars text file should be located inside of the v8_clang-3.9.0-centos7 folder.

    Click for full image.

    The OutputEnvVars.txt file contains useful information for setting your system's environment variable.

  3. Press the Windows Key together with the Pause Break Key to open the System Information menu.

    Click for full image.

  4. Click the Advanced System Settings link to open the Advanced sub-menu, which is located in the System Properties menu.

    Click for full image.

  5. Now, click the Environment Variables... button.

    LinuxXC_Step9.png

  6. To add a new System Variable, click the New... button under the System variables list.

    LinuxXC_Step10.png

    If you haven't opened OutputEnvVars.txt yet, please do so before moving onto the next step.

    Click for full image.

  7. After the New System Variable dialog menu opens, copy the LINUX_MULTIARCH_ROOT environment variable setting into the text boxes for the New System Variable dialog.

    Click for full image.

  8. Verifying that the Variable name and Variable value properties were properly filled out, go ahead and click the OK button to accept the New System Variable.

    LinuxXC_Step12.png

  9. If you still have the LINUX_ROOT environment variable, go ahead and Delete it before moving onto the next step.

    LinuxXC_Step13.png

  10. Click the Ok button to save the LINUX_MULTIARCH_ROOT environment variable.

    LinuxXC_Step14.png

  11. Now, click the OK button to close the System Properties menu.

    LinuxXC_Step15.png

  12. Now that you've added a new Environment Variable to your system, you'll need to close and restart all currently running instances of Visual Studio and Command Prompt.

  13. To verify that you've properly set the LINUX_MULTIARCH_ROOT environment variable, go ahead and open a new Command Prompt and enter %LINUX_MULTIARCH_ROOT%\x86_64-unknown-linux-gnu\bin\clang++ --version into the commandline.

    LinuxXC_Step16.png

    Regardless of the [ROOT] and folder name shown in our sample output, you should see something similar in your Command Prompt.

Setting up the Linux Build Configuration

If you've never packaged a project for Linux before, you'll want to follow these steps.

  1. Opening the Command Prompt, run Setup.bat to check for, update, and install prerequisite dependencies for building UE4 from Visual Studio.

    LinuxXC_Step17.png

  2. Run GenerateProjectFiles.bat to set up the project files for UE4.

    LinuxXC_Step18.png

    GenerateProjectFiles.bat must be run inside of the root folder that UE4 resides in ([UE4 ROOT]). If you run the batch file with Unreal Game Sync , Linux won't show up as a valid Build Configuration inside of Visual Studio.

  3. Navigating to [UE4 ROOT], double-click UE4.sln to open the UE4 solution in Visual Studio.

    Click for full image.

  4. If you haven't built UE4, go ahead and press the F5 key to build and run UE4 from Visual Studio.

    Click for full image.

  5. Now, stop running the engine, and go back to Visual Studio to select the Linux solution platform in Visual Studio. You can build for Linux by pressing the following keyboard combination: Ctrl+Shift+B.

    Click for full image.

    At this point, you should see the toolchain being displayed inside of Visual Studio's Output Window.

    Click for full image.

End Result

Congratulations! Moving forward, you should be able to see the cross-compile toolchain being used while packaging your project for Linux.

Click for full image.

Now, you're ready to compile , build , and package projects for a variety of Linux platforms from your Windows (host) computer.

Tags