Installing Agar on Linux
This guide describes how to compile, and install Agar on Debian, Fedora Linux Mint Ubuntu, and similar Linux distributions.
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
First download the Agar source package and unpack it to a temporary location:
$ wget http://stable.hypertriton.com/agar/agar-1.6.0.tar.gz $ tar -xzf agar-1.6.0.tar.gz $ cd agar-1.6.0
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.
If thread safety is not required, --disable-threads
will improve
performance.
$ ./configure --prefix=$HOME # install in alternate location $ ./configure --enable-debug # debugging features (expensive) $ ./configure --disable-threads # if multithreading is not needed $ 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
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 contains a test suite named 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 # Use SDL (frame-buffer mode) $ ./agartest -d sdlgl # Use SDL (OpenGL mode) $ ./agartest -d 'sdlgl(out=%08d.jpg)' # Capture frames to JPEG files $ ./agartest -d 'glx(stereo)' # Use X11 and OpenGL with stereoscopic view
