In this project, we will show you how you can run x64 software on a Raspberry Pi by using Box64.
Box64 is a unique piece of software that allows us to emulate the x64 architecture on an ARM64 device like the Raspberry Pi 4.
Simply put, this software works by taking an x64 instruction and converting that to an equivalent set of ARM64 instructions.
Box64 does some additional optimizations by dynamically recompiling the x64 code into something that will run better on an ARM64 device.
This software is primarily developed by the same developer behind the excellent x86 emulator called Box86. If you like using this emulator, be sure to consider donating to ptitSeb to support their work.
If you are using a 32-bit operating system, you can instead use Box86, which will allow you to run x86 applications on your Raspberry Pi.
Below is a list of the equipment we used when getting the x64 emulator running on the Raspberry Pi.
Preparing your Raspberry Pi for Box64
Before we can start running x64 applications on our Raspberry Pi, we will need to first prepare it to compile the software we will be relying on.
There are a couple of packages that we will need to install on the operating system before proceeding.
1. Please note that you must be running a 64-bit operating system to use Box64 on your Pi.
This software will not allow you to run 64-bit software on a 32-bit system. It is purely for running x64 software on an ARM64 system.
2. Before proceeding, we should first ensure that our operating system is up to date.
All we need to do is run the following two commands. The first will update the package list, the second will upgrade any out-of-date package.
sudo apt update sudo apt upgrade -y
3. Our next step is to install all packages that we need to compile box64 on the Raspberry Pi.
Run the following command to install these packages to your Pi.
sudo apt install git build-essential cmake
The first package we install is called “
git“. It will allow us to easily pull the latest version of the box64 code to our Raspberry Pi.
Our next package is “
build-essential“. This is a meta-package that installs several other small packages. These packages are used to compile the box64 code itself.
Finally, we install “
cmake“. This package is used to generate the build configuration files that tell the compiler how to operate.
4. Now that we have everything we need, we can finally clone the box64 code to the Pi.
To clone the code, you can use the following command on your device. This command will get the latest version of the code from the Box64 GitHub repository.
git clone https://github.com/ptitSeb/box64.git
Compiling Box64 on your Raspberry Pi
With our Raspberry Pi prepared, we can now compile the x64 emulator on our Raspberry Pi. This process is relatively straightforward as we now have everything we require.
1. Our first step is to change into the directory where we freshly cloned the Box64 source code.
We can use the cd command to change into the correct directory.
We use the tilde (“
~“) symbol so that we change to a folder called “
box64” in the user’s home directory. Therefore, if you cloned Box64 to a different location, make sure that you change this to a fixed path.
2. Now, we need to make a directory where the x64 emulator will be compiled on our Raspberry Pi.
We are going to keep this simple and call this directory “
build“. We will also change into this new directory.
mkdir build cd build
3. We will next need to generate the configuration files so that our Raspberry Pi will know how exactly to compile box64.
We can generate the configuration files needed to compile the x64 emulator by using the command below.
cmake .. -DRPI4ARM64=1 -DCMAKE_BUILD_TYPE=RelWithDebInfo
In this case,
cmake will use the “
CMakeLists.txt” file in the directory above the current one (
We pass in two options that set a couple of variables. These variables help dictate what system we are building Box64 for.
4. Finally, we can use “
make” to compile the Box64 code. The make tool will utilize the information generated by CMake to compile your code.
Run the following command to begin the compilation process.
Using the “
-j” option, we can tell the compiler how many processes it should use to compile the code. Finally, we use the “
nproc” environment variable as it contains the number of cores our CPU has.
5. Once your Raspberry Pi finishes compiling the x64 emulator, we will now need to install it.
You can install Box64 by running the following command on your Pi.
sudo make install
6. Before your Raspberry Pi will know to use these files, we will need to restart the “
Restarting the service will allow the Pi to understand that it can use Box64 to run x64 applications. Without restarting this service, you will run into errors complaining that the file is in an invalid file.
To restart this service, you only need to use the following command.
sudo systemctl restart systemd-binfmt
If you run into any issues when attempting to restart the service, you will need to restart your Raspberry Pi.
Restarting the Pi is as simple as running the following command.
Running an x64 Application using Box64 on your Raspberry Pi
At this stage, you should now have the x64 emulator installed and operating on your Raspberry Pi. To show that this is working, we should attempt to install an x64 application.
To give you an idea of how the Box64 software works, we will start up a Factorio dedicated server on our Raspberry Pi. This is the perfect piece of software as it is only available as a 64-bit Linux binary.
1. Our first step is to download the latest version of the headless build of Factorio. Luckily for us, the Factorio team has provided a simple endpoint from which we can download the latest version.
Run the following command to download the headless build of Factorio.
wget https://factorio.com/get-download/stable/headless/linux64 -O factorio.tar.xz
2. With the archive now downloaded, we need to extract its contents to your Pi so that we can run the server.
You can extract the archive to your Pi by running the following command.
tar -xJf factorio.tar.xz
3. With Factorio now downloaded, we need to utilize it to generate a save game for the server to start from.
The simplest way to do this is to pass in the “
--create” option followed by the location where we want this save file kept.
/home/pi/factorio/bin/x64/factorio --create /home/pi/factorio/saves/my-save.zip
Please note this process can take some time as the server needs to generate the starting map.
When you start up any x64 based application, you can immediately see that Box64 is emulating it to run on your Pi. You will see a message like the following when the application starts.
Box64 with Dynarec v0.1.3 fce5aa5 built on Aug 12 2021 09:46:45
4. Now that we have a save game created, we can launch the dedicated server by referencing the save file.
Use the following command to start up the Factorio dedicated server on your Raspberry Pi.
/home/pi/factorio/bin/x64/factorio --start-server /home/pi/factorio/saves/my-save.zip
At this point, you should now have the Factorio server up and running on your device. Thanks to this, you can see the magic of Box64 at work with it successfully emulating an x64 application on your ARM64 device.
At this stage, you should have successfully compiled and installed the Box64 emulator on your Raspberry Pi.
Box64, of course, isn’t flawless, and there will always be some slowdown introduced by the emulation process.
Thanks to this software, you will now be able to run x64 applications on your Raspberry Pi.
If you experience any errors when running an application, you should report it on the official GitHub with as much information as you can provide.
If you run into any errors with compiling and installing Box64 to your Raspberry Pi, please comment below.
Be sure to also check out some of our other great Raspberry Pi projects.