<-- Back to Documentation

Installing Agar on MacOS X

This guide describes how to install and use the Agar library under Mac OS X. You can develop Agar applications using either Xcode or the command-line.

Installing a precompiled Framework

Precompiled Frameworks for Agar releases are available from the Agar download page. If you are using a precompiled framework, you can ignore the rest of this guide and skip directly to the Agar API Reference.

Compiling Agar itself

The following section describes the preferred method for compiling Agar from source on MacOS X.


Your system should have a working Xcode installation with the Xcode "Command Line Tools". Start up Xcode, click on "Xcode / Preferences" and bring the "Downloads" tab forward. Click on the "Install" button right of "Command Line Tools". The download may take some time.

On Mac OS X, Agar's native Cocoa driver is used by default. If you require support for the SDL 1.x display drivers (sdlfb and sdlgl), make sure that the SDL 1.2.x library is installed (Agar's configure script should detect it whether it's installed in the standard Unix fashion, or as a framework in /Library/Frameworks).

Compilation/Installation Procedure

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

  $ 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` ElectronTubeStore