Agar

   <-- Back to Documentation

Installing Agar on Linux

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

Prerequisites

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

  # apt-get install clang              # Debian, Linux Mint, 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).

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

Agar uses the native X.org 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, Linux Mint, 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, Linux Mint, Ubuntu
  # apt-get install libpng-dev         # Debian, Linux Mint, Ubuntu
Installation Procedure

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

  $ wget http://stable.hypertriton.com/agar/agar-1.5.0.tar.gz
  $ 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 ld.so cache. If you've installed into /usr/local, then your ld.so should be configured to look there:

  # echo "/usr/local/lib" >> /etc/ld.so.conf	# 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>
  
  int
  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!");
          AG_WindowShow(win);
          AG_EventLoop();
          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
Csoft.net ElectronTubeStore.com