Agar Logo

   <-- Retour vers la Documentation

Installer Agar sur Windows (8.1 et versions ulterieures) - LibAgar

Last update: February 24, 2023

This guide describes the recommended procedure for producing a native Windows build of Agar (and Agar applications) under MSYS2. The MSYS2 environment requires 64-bit Windows 8.1 or newer.

Installing MSYS2

Before you continue, make sure that your MSYS2 installation is up to date. You can download the installer from www.msys2.org.

Installing required packages

You can install packages using the pacman -S command. We will assume that you are using MSYS64 UCRT under x86_64. If you are using a different build environment, substitute the mingw-w64-ucrt-x86_64 part in the package name.

The following packages are required:

  • make
  • pkgconf
  • mingw-w64-ucrt-x86_64-gcc (or other C compiler of your choice)
  • mingw-w64-ucrt-x86_64-freetype (1)

(1) Building without FreeType is possible but the typography will be limited to a simple bitmap font engine.

The following packages are recommended:

  • mingw-w64-ucrt-x86_64-fontconfig (for system font discovery).
  • mingw-w64-ucrt-x86_64-mesa (for wgl and other OpenGL drivers).
  • msys2-w32api-headers (for the wgl driver).
  • msys2-w32api-runtime (for the wgl driver).
  • mingw-w64-ucrt-x86_64-SDL2 (for the sdl2mw, sdl2fb and sdl2gl drivers).
  • mingw-w64-ucrt-x86_64-libpng (for PNG image file support).

The following packages are optional:

  • mingw-w64-ucrt-x86_64-libjpeg-turbo (for JPEG image file support).
  • mingw-w64-ucrt-x86_64-SDL (for the SDL 1.2 sdlfb and sdlgl drivers, do not use if using SDL2).
  • mingw-w64-ucrt-x86_64-gettext (for native-language support).
  • mingw-w64-ucrt-x86_64-libiconv (for non-Unicode/non-ASCII character set support).
  • mingw-w64-ucrt-x86_64-winpthreads-git (for thread-safety / multithreading).

Developers may also wish to install:

  • man (agar provides extensive manual pages with code examples)
  • mingw-w64-ucrt-x86_64-gdb (for debugging)
  • patch (for applying patches)
  • perl (for concurrent-building or regenerating ./configure)
  • subversion (use svn co https://dev.csoft.net/agar/trunk to clone Agar sources)
  • vim (syntax files are available from the syntax/ directory)
  • zip, unzip (for building binary packages)
Agar installation

Download or clone 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=/ucrt64 \
      --enable-debug \
      --enable-sg \
      --with-{freetype,sdl2,png,jpeg,gl}=/ucrt64 \
      --without-{fontconfig,gettext,iconv}
  
  $ make && 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 never be used in release builds.
  • --disable-threads will improve performance in cases where thread-safety is not needed.
  • Omit --with-sdl2 if the SDL2 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 and --with-gettext=/ucrt64. If you need support for character sets other than Unicode and ASCII, use --with-iconv=/ucrt64.

Manual pages are installed by default, so you should be able to use the following in the msys2 console:

  $ man AG_Intro

If don't need an offline copy of the manual pages, you can speed up the install using --without-manpages.

Test suite installation

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

  $ cd tests
  $ ./configure --host=x86_64-w64-mingw32 \
      --prefix=/ucrt64 \
      --with-agar=/ucrt64
  $ make && make install

Then execute the installed agartest.exe in the /ucrt64/bin directory.

You can also check that Agar is working with the following example (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:

  $ gcc -o hello \
      `agar-config --cflags` hello.c \
      `agar-config --libs`
Screenshots
Tests from agartest running on Windows 10 (MSYS2 build)

Csoft.net ElectronTubeStore