Agar Tutorial

This tutorial describes how to compile the Agar widget toolkit for the development of applications that have a graphical user interface.

  1. If you haven't done so already, run through the Wingo Tutorial or install some other window manager.

  2. Install the following packages from DPorts.

    • llvm34 (on DragonFly BSD 4.0rc3)
    • pkgconf
    • subversion

  3. Update the llvm34 shared libraries. Restarting is overkill but it works, so restart DragonFly BSD.

  4. Set up your working environment. Run the following commands.

    mkdir -p $HOME/agar/local
    cd $HOME/agar/local
    svn checkout https://dev.csoft.net/agar/trunk src

  5. Configuration settings needs to be changed so that Agar will finish compiling. Skim through $HOME/agar/local/src/configure to find the following two sets of lines.

    *-*-freebsd*)
    PTHREADS_XOPEN_CFLAGS=""

  6. Edit the previous two sets of lines to match the following two sets of lines and save the changes to disk.

    *-*-dragonfly*|*-*-freebsd*)
    PTHREADS_XOPEN_CFLAGS=""

  7. Configure and compile Agar. Then create a directory in which to run an example program. Run the following commands.

    cd $HOME/agar/local/src
    ./configure --prefix=$HOME/agar/local
    make depend all
    make install
    make clean
    mkdir -p $HOME/agar/examples

  8. Write a small example program to verify that Agar successfully compiled. Create the file $HOME/agar/examples/hello.c then add the following lines to it and save the change to disk.

    // Taken from http://libagar.org/docs/inst/bsd.html
    #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) {
        return (1);
      }
      win = AG_WindowNew(0);
      AG_LabelNew(win, 0, "Hello, world!");
      AG_WindowShow(win);
      AG_EventLoop();
      return (0);
    }

  9. Update your shared library cache, make the agar-config script executable, and then compile and run an example program. Run the following commands.

    sudo ldconfig -im $HOME/agar/local/lib
    cd $HOME/agar/examples
    chmod +x ../local/src/agar-config
    cc -o hello `../local/src/agar-config --cflags` hello.c `../local/src/agar-config --libs`
    ./hello

  10. To quit the program, press ctrl-c in the terminal window.
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License