Installing Agar on BSD-like platforms - LibAgar
This guide describes how to compile and install libagar under BSD-like platforms such as FreeBSD, NetBSD and OpenBSD.
Agar works best with OpenGL and the FreeType font engine installed. If you have a working X installation then those components should be already installed on your system.
Agar uses the native X.org API by default, but Agar applications can
be made to work over
SDL 1.2
as well.
In general it's recommended for developers to test their applications
under both
glx
as well as
sdlfb &
sdlgl.
Optional Agar features also make use of the jpeg
, png
and iconv
libraries if those are available.
- FreeBSD:
pkg install agar
- OpenBSD:
pkg_add agar
- FreeBSD:
(cd /usr/ports/devel/agar && make install)
- OpenBSD:
(cd /usr/ports/x11/agar && make install)
First download the Agar source package and unpack it to a temporary location:
$ wget http://stable.hypertriton.com/agar/agar-1.7.0.tar.gz $ 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.
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 to 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
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`
The tests directory contains a test suite named agartest:
$ cd tests $ ./configure && make # make install $ ./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