<-- Back to Documentation

Installing Agar on Linux

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


A standard C compiler such as clang or GCC is required in order to compile Agar:

  # apt-get install clang     # Debian, Ubuntu
  # yum install gcc           # Fedora

For regular desktop usage, OpenGL and FreeType are recommended. The fontconfig library is recommended since it allows all installed fonts on the system to be referenced by Agar (and displayed by AG_FontSelector).

  # yum install mesa-libGL-devel      # Fedora
  # yum install freetype-devel        # Fedora
  # yum install libXinerama-devel     # Fedora
  # yum install fontconfig-devel      # Fedora
  # apt-get install libgl1-mesa-dev    # Debian
  # apt-get install libfreetype6-dev   # Debian, Ubuntu
  # apt-get install libxinerama-dev    # Debian, Ubuntu
  # apt-get install libfontconfig-dev  # Debian, Ubuntu

Agar uses the native API by default, but Agar applications can be made to work with SDL 1.2 as well. If you need SDL support, make sure the SDL library is installed:

  # yum install SDL-devel           # Fedora
  # apt-get install libsdl-dev      # Debian, Ubuntu

For the ability to export and load AG_Surface's from JPEG and PNG files, make sure libjpeg and libpng are installed:

  # yum install libjpeg-turbo-devel   # Fedora
  # yum install libpng-devel          # Fedora
  # apt-get install libjpeg-dev			# Debian, Ubuntu
  # apt-get install libpng-dev			# Debian, Ubuntu
Installation Procedure

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

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

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. --enable-debug is recommended for debug builds (but not release builds since it adds many assertions and runtime type safety checks which impacts performance).

  $ ./configure --prefix=$HOME             # Install to alternate location
  $ ./configure --enable-debug             # Enable debugging
  $ ./configure --enable-nls               # Native language support
  $ ./configure --with-memory-model=LARGE  # Support 16-bit/component color,
                                           # 48/64-bpp pixels and 64-bit sizes.
  $ ./configure --with-memory-model=MEDIUM # Support 8-bit/component color,
                                           # 24/32-bpp pixels and 32-bit sizes.
  $ 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:

  # echo "/usr/local/lib" >> /etc/	# Fedora
  # 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) {
		fprintf(stderr, "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`