Skip to content

Build Instructions for Linux

jcm edited this page Nov 26, 2024 · 20 revisions

Note

This page applies to the in-development new build system. For current build instructions, see here.

Table of Contents

1. Install dependencies

Debian-based (Ubuntu, etc.)
  • In a terminal window, install ares dependencies using apt:

    First, install build system dependencies:

    sudo apt install build-essential cmake pkg-config curl git
    

    Compiling with clang, Ninja and Ccache is optional, but generally recommended:

    sudo apt install clang ninja-build ccache
    

    Next, install required ares dependencies:

    sudo apt install \
        libgtk-3-dev \
        libcanberra-gtk-module \
        libgl-dev
    

    Lastly, install optional dependencies (at least one audio driver is recommended):

    sudo apt install \
        libasound2-dev \
        libao-dev \
        libopenal-dev \
        libsdl2-dev \
        libpulse-dev \
        libudev-dev
    

    Installing librashader (via Open Build Service) is also recommended but not required.

Red Hat-based (Fedora, etc.)
  • In a terminal window, install ares dependencies using dnf:

    Build system dependencies:

    sudo dnf install cmake pkg-config curl git
    

    Compiling with clang, Ninja, and Ccache is not required, but generally recommended:

    sudo dnf install clang ninja-build ccache
    

    Next, install required ares dependencies:

    sudo dnf install \
        gtk3-devel \
        libx11-devel \
        libXrandr-devel \
        mesa-libGL-devel 
    

    Lastly, install optional dependencies (at least one audio driver is recommended):

    sudo dnf install \
        openal-soft-devel \
        alsa-lib-devel \
        sdl2-devel \
        pulseaudio-libs-devel
    

    Installing librashader (via Open Build Service) is also recommended but not required.

Other distributions
  • Building ares on other Linux distributions should not present a high degree of difficulty. The primary requirement is that OpenGL and one of ares's audio drivers is supported on the system. The general package requirements are as follows:

    Prerequisites

    • Git
    • CMake 3.28 or higher
    • Clang or GCC
    • pkg-config

    Optional but recommended build tools include:

    • Ninja
    • Ccache

    ares requires development versions of the following packages in order to build:

    • X11
    • libGL
    • GTK3

    Recommended development packages include:

    You may also configure with development packages for other audio drivers:

    • OpenAL
    • AO
    • ALSA
    • PulseAudio

2. Get the source code

  1. In a terminal window, navigate to a directory where you would like to build ares.
  2. Clone the ares repository and change into its directory:
git clone https://github.com/ares-emulator/ares
cd ares

3. Build ares

First, generate a build environment:

mkdir build && cd build
cmake .. -G Ninja

During the above generation step, you can provide a number of configuration options. If you are not using Ninja, you should omit -G Ninja from the cmake invocation above. If you wish to compile with clang but GCC is your default compiler, be sure to pass -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ at the generation step.

See the Build Options page for a full list of configuration options.

Next, build the project:

cmake --build .

If you are building with Makefiles (the default), you should provide the additional -j# argument, where # is the number of processor cores on your machine minus one or two.

With ares built, you may run it from the staging directory:

./rundir/bin/ares

If you want to install ares to another location, you may also optionally do so with CMake:

cmake --install . --prefix </your/chosen/prefix>

For further configuration options, see the Build Options page.

Staging Directory Structure

The build staging directory uses a standard prefix structure described below. Since ares does not ship any libraries, ares can be run freely from this staging directory, and the rundir can also be relocated. It is still, however, recommended to use CMake's --install command to install ares in a particular location. Installs and staging follow CMake GNUInstallDirs conventions for directory naming.

If you wish to not install slang-shaders underneath the ares data directory, pass -DARES_BUNDLE_SHADERS=NO during build configuration.

rundir
  ├─ bin
  │   ├─ ares
  │   └─ sourcery
  └─ share
      ├─ ares
      │   ├─ Database
      │   │     ├─ Arcade.bml
      │   │     ├─ BS Memory.bml
      │   │     ├─ Famicom.bml
      │   │     ├─ MSX.bml
      │   │     ├─ MSX2.bml
      │   │     ├─ Neo Geo.bml
      │   │     ├─ Sufami Turbo.bml
      │   │     ├─ Super Famicom Boards.bml
      │   │     └─ Super Famicom.bml
      │   └─ Shaders
      │         └─ <contents of slang-shaders>
      ├─ applications
      │       └─ ares.desktop
      └─ icons
           └─ hicolor
                 └─ 256x256
                       └─ apps
                            └─ ares.png