Unreal Engine has a nice feature that lets us build distributables (packages) for Linux on a Windows system. It’s a magic known as Cross Compiling. This doesn’t work out of the box, but it’s easy to implement with any Windows version of Unreal Engine. It’s not exactly oblivious how to get started with this magic though, so I thought I’d share what worked for me with version 4.25.
It’s as simple as heeding over to File – Package Project – Linux.
The first time you pick either Linux or AArch64, you’ll be directed to EPIC’s “Getting started with Cross Compiling” page. From here you need to pick what they call a toolchain for your version of Unreal Engine. This is essentially a virtual instance of CentOS that can read and compiles your project with native Linux tools once installed.
Download the EXE file and run it. If you’re upgrading to a newer version of Unreal Engine, the installer lets you un-install older toolschains you no longer need. They’re about 1.5GB each, so it’s worth doing.
Once installed, restart your system. It’s that one vital step nobody tells you about. Without a restart, the environment variables that have been added to your Windows system are not read by Unreal Engine, leading to compiler errors. After the reboot, open your project again and the Linux options under Package Project will work as expected.
What’s the difference between Linux and AArch64 again?
Linux in this context means the 64 bit version of the Intel/AMD architecture, also known as x86-64. Any distribution running an Intel or AMD CPU should be able to run this Linux build (provided they have Vulkan drivers installed, and are 64 bit versions).
AArch64 targets any 64-bit Linux distribution running on the ARM architecture.
As of Unreal Engine 4.16, only 64-bit packages can be build from Windows. There was a way to create 32-bit executables with 4.15 and below, but from what I understand it’s a major headache trying to do this with current versions of Unreal Engine.
Can we build something for macOS from Windows?
Sadly not, the macOS version of Unreal Engine relies on Apple’s Xcode to do the compiling, and that’s not available on Windows. To build a macOS executable, you’ll have to install Unreal Engine on a compatible Mac. My Mac Mini from 2012 can just about run macOS Mojave, which is just about compatible with Unreal Engine 4.26. Anything higher than that, we’ll have to wait and see.