bevy/docs/linux_dependencies.md
Daniel McNab 0aced5fb72 Revert #331 (#2502)
# Objective

@TomBebb (other account being @TomBebbington ) proved unreachable for #2373, so we need to revert their changes for the relicense.

## Solution

Revert their changes. This is only linux distro docs, so it's not critical code.

If someone else wants to test `bevy` on solus to work out the set of packages independently, then we'll probably accept a PR to add these. One suggestsion would be to consider the packages required on other systems, since there is likely to be some overlap.

## Alternatives

Link to this old version in the `linux_dependencies.md` file.
2021-07-19 21:13:30 +00:00

2.9 KiB

Installing Linux dependencies

This page lists the required dependencies to build a Bevy project on your Linux machine.

If you don't see your distro present in the list, feel free to add the instructions in this document.

Ubuntu 20.04

sudo apt-get install g++ pkg-config libx11-dev libasound2-dev libudev-dev

Depending on your graphics card, you may have to install one of the following: vulkan-radeon, vulkan-intel, or mesa-vulkan-drivers

Compiling with clang is also possible - replace the g++ package with clang.

Windows Subsystem for Linux (WSL 2)

Graphics and audio need to be configured for them to work with WSL 2 backend. Please see the ubuntu WSL documentation on how to set up graphics and audio.

Fedora

sudo dnf install gcc-c++ libX11-devel alsa-lib-devel systemd-devel

If there are errors with linking during the build process such as:

 = note: /usr/bin/ld: skipping incompatible /usr/lib/libasound.so when searching for -lasound
          /usr/bin/ld: skipping incompatible /usr/lib/libasound.so when searching for -lasound
          /usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-redhat-linux/10/../../../libasound.so when searching for -lasound
          /usr/bin/ld: skipping incompatible /lib/libasound.so when searching for -lasound
          /usr/bin/ld: skipping incompatible /usr/lib/libasound.so when searching for -lasound
          /usr/bin/ld: cannot find -lasound

Add your arch to the end of the package to remove the linker error. For example:

sudo dnf install alsa-lib-devel.x86_64

Arch / Manjaro

sudo pacman -S libx11 pkgconf alsa-lib

Void

sudo xbps-install -S pkgconf alsa-lib-devel libX11-devel eudev-libudev-devel

NixOS

Add a build.rs file to your project containing:

# build.rs

fn main() {
    if cfg!(target_os = "linux") {
        println!("cargo:rustc-link-lib=vulkan");
    }
}

These packages provide the dependencies required to run a bevy project. They can be installed globally or via nix-shell. Based on your global configuration it also might be necessary to allow unfree packages:

export NIXPKGS_ALLOW_UNFREE=1 # needed for lutris
nix-shell -p cargo pkgconfig udev lutris alsaLib x11 xorg.libXcursor xorg.libXrandr xorg.libXi vulkan-tools vulkan-headers vulkan-loader vulkan-validation-layers

Alternatively, you can define shell.nix containing:

# shell.nix

{ pkgs ? import <nixpkgs> { } }:
with pkgs;
mkShell {
  buildInputs = [
    cargo
    pkgconfig udev alsaLib lutris
    x11 xorg.libXcursor xorg.libXrandr xorg.libXi
    vulkan-tools vulkan-headers vulkan-loader vulkan-validation-layers
  ];
}

And enter it by just running nix-shell.

You should be able compile bevy programms using cargo within this nix-shell.

Opensuse Tumbleweed

   sudo zypper install libudev-devel gcc-c++