<-- Back to Documentation

Installing Agar on Linux

This guide describes how to compile and install the Agar library under common Linux distributions such as Debian, Ubuntu and Fedora. If your particular distribution provides some kind of software manager, you want may to look for an Agar package (note: if a package is outdated compared to the most recent release of Agar, we recommend compiling from source instead).


A standard C compiler is needed to compile Agar. Most likely, you'll already have some version of GCC installed. If not, you'll need to install one:

  # yum install gcc				# Fedora

Agar works best with OpenGL and the FreeType font engine installed. Provided that you have a working desktop, those components should be already installed on your system, but since you are compiling from source, the following "dev" packages may be needed:

  # yum install mesa-libGL-devel		# Fedora
  # yum install freetype-devel			# Fedora
  # yum install libXinerama-devel		# Fedora
  # apt-get install libgl1-mesa-dev		# Debian
  # apt-get install libfreetype6-dev		# Debian/Ubuntu
  # apt-get install libxinerama-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 libsdl1.2debian-all		# Debian
  # apt-get install libsdl-dev			# Debian/Ubuntu

Some optional Agar features also make use of the jpeg and png libraries if they are available.

  # 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. The --enable-debug option is recommended for developers, since it enables assertions and type safety checking in event handler arguments.

  $ ./configure --prefix=$HOME		# Install to some alternate location
  $ ./configure --enable-debug		# For developers
  $ ./configure --enable-nls		# Enable native language support
  $ make depend all

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`