Building Linux Server from source on Linux

I followed this thread from a distance, to resume the steps :

  • git clone https://github.com/citizenfx/fivem.git
  • cd fivem
  • git submodule update --init --recursive I have somes issues with circular dependencies where with EABase and EAStl, might need to ignore those when recursive cloning
  • Remove svadhesive from fivem/data/server/components.json and fivem/data/server_windows/components.json
  • docker pull mcr.microsoft.com/dotnet/core/sdk:3.1-alpine3.13
  • docker run -it -v "$(pwd)":/src mcr.microsoft.com/dotnet/core/sdk:3.1-alpine3.13 /bin/sh
  • From the container : chmod +x /src/code/tools/ci/build_server_2.sh
  • From the container : /src/code/tools/ci/build_server_2.sh
  • From the container : cp /opt/cfx-server /src/build -r
  • The build folder on the host should contain the built server

Is that correct ?

Will that allow server owners to host on different cpu architecture that the official release offers ? I wanted to try on RPI4 for instance

You’ll likely have an issue with dependencies there including having a ‘fun time’ reproducing the v8/mono dependencies.

This is fairly low priority to make reproducible sadly.

On a Raspberry Pi or Azure AArch64 instance you can however run Windows to use XTAJIT64, or on general AArch64 Linux systems you can try your luck with binary translators like Huawei ExaGear or FEX-Emu.

You need to run a modified version of build_server_proot.sh (it sets up the environment and then runs build_server_2.sh). I have published my version here, or you can modify and customize it yourself.

You also need to add:

cp -a ../data/server_windows/citizen/clr2/lib/mono/4.5/System.Runtime.InteropServices.RuntimeInformation.dll /usr/lib/mono/4.5

to build_server_2.sh before the loop that copies .dlls (around line 171).

The built server should be in the alpine folder in the root of your fivem repo clone if you mounted everything correctly. It will have just the server part of the process described here, you can copy over the run.sh script from the official release or find it in the project source.

Sadly I am extremely busy and cannot devote almost any time to tinkering with FiveM anymore like I could in the past, so I did not make this build process user-friendly. I don’t plan to repeat this often. The goal is to build a server that somewhat works once in a long while and then just use it.