Agar Logo

   <-- Retour vers la Documentation

Installater Agar sur MacOS - LibAgar

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

Compiling the Agar library

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

Prerequisites

Your system should have an Xcode package installed (with Xcode "Command Line Tools" included). 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.

Under MacOS the cocoa driver is the one used by default. The sdlfb and sdlgl drivers are made available if the SDL 1.2.x library or SDL framework can be found.

Compilation/Installation Procedure

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

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

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.

  • --enable-debug is recommended for developer use since it enables (expensive) run-time assertions and type safety checks.
  • If thread safety is not required, --disable-threads will improve performance.
  $ ./configure --prefix=$HOME      # install in some alternate location
  $ ./configure --enable-debug      # debugging features (expensive)
  $ ./configure --disable-threads   # if multithreading is not needed

  $ make

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 (hello world)

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

  #include <agar/core.h>
  #include <agar/gui.h>

  int
  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!");
          AG_WindowShow(win);
          AG_EventLoop();
          return (0);
  }

Compile this example using:

  $ cc -o hello `agar-config --cflags` hello.c `agar-config --libs`
Running agartest (interactive test suite)

The tests directory contains an interactive test suite named agartest:

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

  $ open agartest.app

Csoft.net ElectronTubeStore