Agar Logo

   <-- Back to Documentation

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

This guide describes a procedure for producing a native 64-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 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 ensure that the following packages are enabled:

  • Devel / make
  • Devel / gcc-core
  • Devel / mingw64-x86_64-binutils
  • Devel / mingw64-x86_64-gcc-core
  • Devel / mingw64-x86_64-pthreads
  • Devel / mingw64-x86_64-runtime

The following packages are optional:

  • Devel / mingw64-x86_64-freetype2 (recommended font engine)
  • Devel / mingw64-x86_64-libjpeg-turbo (for JPEG image support)
  • Devel / mingw64-x86_64-libpng (for PNG image support)
  • Devel / mingw64-x86_64-SDL (recommended, enables sdlfb and sdlgl drivers)
  • Devel / mingw64-x86_64-gettext (multi-language support)
  • Devel / mingw64-x86_64-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/x86_64-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.7.0.tar.gz
  $ cd agar-1.7.0
  $ ./configure --host=x86_64-w64-mingw32 \
      --prefix=$MINGWROOT \
      --enable-debug \
      --with-{freetype,sdl2,png,jpeg,gl}=$MINGWROOT \
      --without-{fontconfig,gettext,iconv}
  $ 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.
  • Omit --with-sdl2 if the SDL2 driver is not needed. For SDL 1.x support, you can use --with-sdl instead (cannot be used along with SDL2).
  • Omit --with-png and --with-jpeg if the ability to load images in PNG and JPEG format is not required.
  • For native language support, 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.7.0/tests
  $ ./configure --host=x86_64-w64-mingw32 \
      --prefix=$MINGWROOT \
      --with-agar=$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>
  
  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);
  }

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

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

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.


Csoft.net ElectronTubeStore