Agar Logo

   <-- Back to Documentation

Installing Agar on Windows XP, 7 and Earlier (MinGW32) - LibAgar

This guide describes a procedure for producing a native 32-bit Windows build of Agar and Agar applications on Windows XP, Windows 7 and earlier using the Cygwin build environment.

For 64-bit builds on Windows 8.1 and up, see the following instead: Installing on Windows with MSYS2.

We are cross-compiling to a MinGW host, so the build will consist of native Windows executables and DLLs. This may be done from the Cygwin shell, MSYS, a BSD or Linux system, or any other environment where a MinGW cross-compiler is available.

The Cygwin environment is convenient for cross-compiling since most of the MinGW cross-compilation environment is already available in binary package form.

The procedure described here was tested on fresh install of Windows XP and Windows 7 (64-bit), with all available updates installed.

Installing required Cygwin packages

Before you continue, make sure that your Cygwin installation is up to date. Run Cygwin Setup and check that the following packages are enabled. To install sources for a particular package, check the box under the "Src?" column in the Cygwin installer.

  • Devel / make
  • Devel / gcc-core
  • Devel / patch
  • Devel / mingw64-i686-binutils
  • Devel / mingw64-i686-gcc-core
  • Devel / mingw64-i686-pthreads
  • Devel / mingw64-i686-runtime

The following packages are optional:

  • Devel / mingw64-i686-freetype2 (recommended font engine)
  • Devel / mingw64-i686-libjpeg-turbo (for JPEG image support)
  • Devel / mingw64-i686-libpng (for PNG image support)
  • Devel / mingw64-i686-SDL (recommended, enables sdlfb and sdlgl drivers)
  • Devel / mingw64-i686-gettext (multi-language support)
  • Devel / mingw64-i686-win-iconv (extra encodings support)

Developers may also wish to install:

  • Archive / unzip
  • Devel / gdb
  • Devel / patch
  • Devel / subversion
  • Interpreters / perl (enables support for separate building with ./configure --srcdir=path)
Setting up the environment

Start up the Cygwin shell. Set the $MINGWROOT environment variable to the installation directory. For quick access, you may also wish to create a shortcut to this directory in your Desktop or Favorites.

  export MINGWROOT=/usr/i686-w64-mingw32/sys-root/mingw

It is good practice to use -g in your global compiler flags, so that debugging information will be included in the build:

  export CFLAGS="-O2 -g"
  export CXXFLAGS="-O2 -g"

Using -O0 instead of -O2 can also improve the debugger's ability to produce reliable traces.

Agar installation

Download the Agar sources, compile and install using:

  $ tar -xzf agar-1.6.0.tar.gz
  $ cd agar-1.6.0
  $ ./configure --host=i686-w64-mingw32 \
      --prefix=$MINGWROOT \
      --enable-debug \
      --with-{freetype,sdl,png,jpeg,gl}=$MINGWROOT \
  $ make depend all && make install

There are a number of build options available (see ./configure --help).

  • --enable-debug is recommended for developers since it enables assertions and type safety checking for event handler arguments. It impacts performance significantly and should not be used in release builds.
  • --disable-threads will improve performance if thread-safety is not needed.
  • Omit --with-sdl if the SDL drivers are not needed.
  • Omit --with-png and --with-jpeg if the ability to load images in PNG and JPEG format is not required.
  • If native language support is needed add --enable-nls, --with-iconv=$MINGWROOT and --with-gettext=$MINGWROOT.

If you wish to make the Agar manual available from cygwin's manual reader, append $MINGWROOT/share/man to your /etc/man.conf. If you don't need the manual installed, using the ./configure --without-manpages option will speed up the build process.

Test suite installation

Agar provides a test suite for developers, agartest.exe. It must be compiled and installed separately.

  $ cd agar-1.6.0/tests
  $ ./configure --host=i686-w64-mingw32 \
      --prefix=$MINGWROOT \
  $ make depend all && make install

Then execute the installed agartest.exe in the $MINGWROOT\bin directory.

You can also check that Agar is working with hello.c:

  #include <agar/core.h>
  #include <agar/gui.h>
  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!");
          return (0);

To compile hello.c as a standalone Windows executable, use:

  $ i686-w64-mingw32-gcc -o hello \
      `$MINGWROOT/bin/agar-config --cflags` hello.c \
      `$MINGWROOT/bin/agar-config --libs`

1) If you are using Agar's wgl driver (the default on Windows) and your application freezes a few seconds after focus is switched to a different application, this is an Aero bug affecting OpenGL applications. To disable Aero, right-click on the Windows Desktop, click on Personalize, and select a basic theme such as "Windows Classic". Alternatively, you can work around this problem using a compatibility tweak: right-click on your application .exe file, go to Properties / Compatibility, and check the "Disable visual themes" option. ElectronTubeStore