<-- Back to Documentation

Installing Agar on BSD-like platforms

This guide describes how to compile and install the Agar library under BSD-like platforms such as FreeBSD, NetBSD and OpenBSD. Before compiling, you might want to search the ports/packages collection for an Agar package. However, if an available package is outdated compared to the most recent release of Agar, we recommend installing from source instead.


Agar works best with OpenGL and the FreeType font engine installed. Provided that you have a working installation (such as x11/xorg on FreeBSD), those components should be already installed on your system.

Agar uses the native API by default, but Agar applications can be made to work over SDL 1.2 as well. If you need SDL support, make sure the sdl package is installed. Some optional Agar features also make use of the jpeg, png and iconv libraries if those are available.

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

Then configure and compile the sources. There are a number of build options available (see ./configure --help), but the defaults should be fine unless you have specific requirements. 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. This will install under the /usr/local by default (you can use the configure option --prefix to install to an alternate location).

  # make install
Testing Agar

You can test that Agar is working using a simple hello.c program like so:

  #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`

The tests directory in the Agar distribution contains a test suite called agartest:

  $ cd tests
  $ ./configure && make

  $ ./agartest
  $ ./agartest -C                       # Console output to terminal
  $ ./agartest -s blue.css              # Alternate stylesheet
  $ ./agartest -t Courier:12            # Alternate font
  $ ./agartest -d sdlfb                 # Alternate graphics backend (SDL)
  $ ./agartest -d 'glx(stereo)'         # Stereoscopic display under X
  $ ./agartest -d 'sdlgl(out=%08d.jpg)' # Capture frames to JPEG files