Skip to content

Build from source

Azkoh edited this page Sep 26, 2021 · 51 revisions

Build from source

Preferred IDE (optional): Visual Studio Code with rust-analyzer extension

Build server

On the repository root execute:

cargo xtask build-server --release

ALVR server will be built into /build/alvr_server_windows.

Build client

  • Install rustup
  • Install LLVM
  • Latest version of Android Studio, SDK level 30, NDK v22
  • Environment variable JAVA_HOME set to C:\Program Files\Android\Android Studio\jre
  • Environment variable ANDROID_SDK_ROOT set to %LOCALAPPDATA%\Android\Sdk
  • For building Android dependencies (optional): Python

On the repository root execute:

cargo xtask build-android-deps
cargo xtask build-client --release

ALVR client APKs will be built as /build/alvr_client_*.apk.

Note: You can debug the client normally by opening the Android Studio project at alvr/client/android.

Note: If you have problems running build-android-deps:

  • Go to the nightly CI runs list
  • Open the latest workflow run
  • Download the artifact android-deps
  • Create a deps folder on the project root
  • Unzip android-deps.zip inside the deps folder. You should have the file deps/rust-android-gradle/runst-android-0.8.3.jar

Linux experimental builds

Supported setups

  • AMD using radv is known to work, with hardware encoding
  • AMD using amdvlk does not work
  • NVIDIA using proprietary driver works, with software encoding
  • Intel is untested

Packaged Builds

Fedora

An RPM for ALVR can be built for Fedora (and possibly other RPM-based distros), and is preferred where possible.

  1. Install dnf-utils, git, and RPMFusion
sudo dnf -y install dnf-utils git https://mirrors.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm https://mirrors.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm
  1. Clone the git repository:
git clone https://github.com/alvr-org/ALVR.git
  1. Change to the repository directory:
cd ALVR
  1. Install build dependencies (This will take >1GB space)
sudo yum-builddep -y packaging/rpm/alvr.spec
  1. For a build of the current source, create the source directory and tar the repository:
mkdir -p "${HOME}/rpmbuild/SOURCES"
tar -cvz . > "${HOME}/rpmbuild/SOURCES/$(spectool packaging/rpm/alvr.spec | grep -oP 'v\d+\.\d+\..*\.tar\.gz')"
  1. Build the RPM:
rpmbuild -ba packaging/rpm/alvr.spec

If a build for a specific release is needed, spectool may be used to fetch that release from the specfile instead of using tar in the current working directory.

Unpackaged Builds

Required dependencies

You need rustup and the following platform specific dependencies:

Arch
sudo pacman -S clang curl nasm pkgconf yasm vulkan-headers libva-mesa-driver
# Install ffmpeg-vulkan from the AUR
# Use either
paru -S ffmpeg-vulkan
yay -S ffmpeg-vulkan

However, for now, vulkan-headers must be downgraded to the earliest 1.2.x version. On arch, you can install "downgrade" from the AUR

Gentoo
  • media-video/ffmpeg >= 4.4 [encode vulkan vaapi]
  • sys-libs/libunwind
  • dev-lang/rust >= 1.51
Nix(OS)

Use the shell.nix in packaging/nix.

Ubuntu/Pop!_OS (20.04)

There's a youtube tutorial here

Dependencies:

sudo apt install build-essential pkg-config libclang-dev libssl-dev libasound2-dev libgtk-3-dev libvulkan-dev libunwind-dev gcc-8 g++-8 yasm nasm curl libx264-dev libx265-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev libspeechd-dev libxkbcommon-dev libdrm-dev

Build command

cargo xtask build-server --release

Or, if the ffmpeg package provided by your distribution does not have vulkan support enabled (such as Ubuntu)

cargo xtask build-server --release --bundle-ffmpeg

Troubleshooting

Steam Native on some distro's runs this a little better. To get Steam Native on Ubuntu run it with:

env STEAM_RUNTIME=0 steam

On Arch Linux, you can also get all the required libraries by downloading the steam-native-runtime package from the multilib repository

sudo pacman -S steam-native-runtime

Dependencies might be missing then, so run:

cd ~/.steam/root/ubuntu12_32
file * | grep ELF | cut -d: -f1 | LD_LIBRARY_PATH=. xargs ldd | grep 'not found' | sort | uniq

Some dependencies have to be fixed manually for example instead of forcing a downgrade to libffi version 6 (which could downgrade a bunch of the system) you can do a symlink instead (requires testing):

cd /lib/i386-linux-gnu
ln -s libffi.so.7 libffi.so.6 

and

cd /lib/x86_64-linux-gnu
ln -s libffi.so.7 libffi.so.6