Agar Logo

   <-- Back to Documentation

Installing Agar on Linux - LibAgar

This guide describes how to compile, and install Agar on Debian, Fedora Linux Mint Ubuntu, and similar Linux distributions.


A standard C compiler and build environment are required in order to compile Agar:

  # On Ubuntu:
  # apt install gcc make pkgconf

  # On Debian and Linux Mint:
  # apt-get install clang

  # On Fedora:
  # yum install gcc

The following packages are recommended for regular desktop usage. FreeType is needed for high-quality typography. Fontconfig allows system fonts to be accessed by AG_FontSelector. The PNG library is needed to load bitmap fonts and icons:

  # On Ubuntu:
  # apt install libgl1-mesa-dev libxinerama-dev
  # apt install libfreetype6-dev libfontconfig-dev libpng-dev

  # On Debian and Linux Mint:
  # apt-get install libgl1-mesa-dev libxinerama-dev
  # apt-get install libfreetype6-dev libfontconfig-dev libpng-dev
  # On Fedora:
  # yum install mesa-libGL-devel libXinerama-devel
  # yum install freetype-devel fontconfig-devel libpng-devel

Agar uses the native API by default, but Agar applications can also be made to work with SDL (both 1 and 2). If you want SDL support, make sure the SDL library is installed:

  # On Ubuntu:
  # apt install libsdl2-dev

  # On Debian and Linux Mint:
  # apt-get install libsdl2-dev

  # On Fedora:
  # yum install SDL2-devel

If you want AG_Surface to be able to read and write to JPEG files, make sure that libjpeg is installed:

  # On Ubuntu:
  # apt install libjpeg-dev

  # On Debian and Linux Mint:
  # apt-get install libpng-dev

  # On Fedora:
  # yum install libjpeg-turbo-devel

If you want native-language support, make sure that gettext is installed:

  # On Ubuntu:
  # apt install gettext

  # On Debian and Linux Mint:
  # apt-get install gettext

  # On Fedora:
  # yum install gettext
Installation Procedure

First download the Agar source package and unpack it to a temporary location:

  $ wget
  $ tar -xzf agar-1.7.0.tar.gz
  $ cd agar-1.7.0

Now you can build the sources. There are a number of build options available (see ./configure --help), but unless you have specific requirements, the defaults should be used. The --enable-debug option is recommended for developers, since it enables assertions and type safety checking in event handler arguments. If thread safety is not required, --disable-threads will improve performance.

  $ ./configure --prefix=$HOME      # install in alternate location
  $ ./configure --enable-debug      # debugging features (expensive)
  $ ./configure --disable-threads   # if multithreading is not needed

  $ make

Finally, install the library. Unless you've specified an alternate --prefix, the files will be installed under /usr/local:

  # make install

After the installation, you may need to run ldconfig to refresh the cache. If you've installed into /usr/local, then your should be configured to look there:

  # On Fedora:
  # echo "/usr/local/lib" >> /etc/
  # ldconfig
Testing Agar

At this point, you can test that Agar is working using a simple hello.c program:

  #include <agar/core.h>
  #include <agar/gui.h>
  main(int argc, char *argv)
          AG_Window *win;
          if (AG_InitCore(NULL, 0) == -1 ||
              AG_InitGraphics(0) == -1) {
                  AG_Verbose("Init failed: %s\n", AG_GetError());
                  return (1);
          win = AG_WindowNew(0);
          AG_LabelNew(win, 0, "Hello, world!");
          return (0);

Compile this example using:

  $ cc -o hello `agar-config --cflags` hello.c `agar-config --libs`

The tests directory contains a test suite named agartest:

  # Compile and build agartest:

  $ cd tests
  $ ./configure && make
  # make install

  # Run agartest:

  $ ./agartest
  # Redirect console to terminal:

  $ ./agartest -C

  # Specify an alternate driver:

  $ ./agartest -d sdl2mw  # SDL2 (multi-window GL)
  $ ./agartest -d sdl2gl  # SDL2 (single-window GL)
  $ ./agartest -d sdl2fb  # SDL2 (frame-buffer mode)

  # Capture video output to jpeg files:

  $ ./agartest -d 'sdl2gl(out=%08d.jpg)'

  # Enable stereoscopic vision with the glx driver:

  $ ./agartest -d 'glx(stereo)'

  # Load an alternate stylesheet:

  $ ./agartest -s blue.css

  # Set an alternate default font:

  $ ./agartest -t 'DejaVu Sans:12:Condensed' ElectronTubeStore