The Allegro Wiki is migrating to github at https://github.com/liballeg/allegro_wiki/wiki
Building Allegro 5.1 (rev 15032) Windows 7
Well, first of all I want you to remember, that you should be doing this for educational purposes or because you're very interested in one of the latest features of Allegro 5 and it's only available in the unstable version. There is no need to build Allegro 5 by your own if you want to use it. Just grab the pre-built binaries from the files section on www.allegro.cc and follow the installation instruction.
Like always in programming you'll need a compiler, so follow the short MinGW installation tutorial to install MinGW and set your environmental variables, this last step is very important when compiling Allegro 5 from scratch.
You'll also need Cmake-GUI, this is a program that allows you to configure your library in a more interactive way than the traditional way.
Before we can install Allegro we need to build and install first a bunch of libraries that are used by Allegro 5, so let's the party begins.
Necessary Libraries (Allegro 5 dependencies):
- CG Toolkit-bin
- OpenAL Soft
These are the minimum amount of libraries you'll need to build Allegro 5 and work fine with it, there are others, like:
cURL: To be able to compile one of the examples.
PDFlatex: To get a PDF version of the Manual.
Tremor: An alternative of Vorbis. Is a fixed-point version of the Vorbis decoder for those platforms without floating point operations for embedded devices such as mobile phones.
Next, you'll need to create a "deps" folder inside the Allegro 5.1 folder (the folder that contain the source code), this is where you'll put the libraries already built so Allegro will be able to find them. The advantage of having all your dependencies in this folder is that if you want to change one of the dependencies for a newest one, what you have to do is just delete the library, compile the new one, and re-compile Allegro. Otherwise you could put your libraries inside the MinGW folder but would be more difficult to find the library to delete it, since they're in the same place that other libraries, and they are a lot!
Building / Compiling Dependencies
During this tutorial you'll find yourself going to your MSYS folder a lot. So just to make things easier, let's add that folder to our "Favorites" before we do anything else. To do that, open Explorer and navigate to "C:/MinGW/msys/1.0". On the navigation pane in the left, right-click on "Favorites" and choose "Add current location to Favorites" (You could also drag the folder into your favorites section). It should now appear with the rest of the folders.
Great, we're ready to go. Now let's get building.
Let's start with Zlib. First, download Zlib and save it in "C:/".
Open Cmake-GUI. In "where is the source" section paste the zlib directory and in the "where to build the libraries" section paste a folder where you want to save the the configuration files (already configured), you need to create a folder, mine is going to be called "zlib-ready".
and press "configure".
Select "MinGW Makefiles" and "Use default native compiler"You'll see an error message that says:
You must remove C:/zlib/zconf.h from the source tree. This file is included with zlib but CMake generates this file for you automatically in the build directory.
And what you have to do is exactly that. Go to "C:/zlib" and remove that file.Then change the "CMAKRE_INSTALL_PREFIX" configuration variable to
Where "a5.1" is the name of your Allegro 5.1 folder, mine is called "a5.1".
Press "Configure" again and then "Generate".
Open the console (cmd.exe) and type:
cd c:/zlib-ready mingw32-make
Wait until the process ends, and then type:
And that's it, we have zlib installed in our "deps" folder. You will end up with (minimum) these folders:
but you could also see
include bin docs share
Now what you need to do is put those folders inside another folder called "zlib", because otherwise when you build and install another library, the files are going to be introduced inside the "include" and "lib" folders mixing all up. Otherwise you could insert the complete path, let's say: "C:/a5.1/deps/zlib" in the "CMAKRE_INSTALL_PREFIX" variable, and the folder is going to be created automatically.
That's is the way to build a library when it's using Cmake. Now let's compile one of those which come with a simple "makefile" file.
Delete the "zlib" and "zlib-ready" folders from C:/, since we're not going to use them anymore.
Now past your "libogg" folder with the sources in "C:/" as you did with zlib. I always change the name of the folder as you can see, to keep it simpler. Go to your "1.0" folder shortcut an open the msys.bat file. This is like the command line but as the mingw site says: allow us to build applications and programs which depend on traditionally UNIX tools to be present.
Once is opened type:
cd c: cd libogg
and you should see something like this:
Now, for the configuration process, just type:
If there is somthing you want to change, like where to install the binaries, you have to do it the old school way, remember this isn't Cmake-GUI. Type:
And it'll give you some instructions about what you have to do to change the installation directory, and other things. When I installed zlib with Cmake-GUI I make it install the libraries inside the "deps" folder directly, this time I'm going to do it manually, so as the "./configuration --help" says:
By default, `make install' will install all the files in `/usr/local/bin', `/usr/local/lib' etc. You can specify an installation prefix other than `/usr/local' using `--prefix', for instance `--prefix=$HOME'.
The local folder is inside our "1.0" folder , do not confuse it with the "user" Windows folder.
So we're going to use the default configuration options. Now type:
Wait and then type:
And magically we have the binaries inside our "local" folder. Put them inside a "libogg" folder and copy and paste inside your "deps" folder.
Now remove the files from the local folder since you're going to repeat this process plenty of times and you don't want to mix everything up.
Now let's build Vorbis, the same:
cd c: cd vorbis ./configure make make install
copy and paste.
Next: FLAC, with FLAC I have encounter a little problem so you're going to do something first, otherwise you'll get an error of this kind:
error: 'SIZE_T_MAX' undeclared (first use in this function)
So open the "limits.h" header file which is in "C:/mingw/include" and scroll to the end until you find this:
/* MSVC compatibility */ #define _I64_MIN LONG_LONG_MIN #define _I64_MAX LONG_LONG_MAX #define _UI64_MAX ULONG_LONG_MAX #endif /* Not Strict ANSI and GNU C compiler */ #define SIZE_T_MAX UINT_MAX /* max value for a size_t */ // < -- PASTE THIS HERE!! #endif /* not _LIMITS_H_ */
And paste the line #define SIZE_T_MAX UINT_MAX /* max value for a size_t */ as you can see in the example above.
Now you can do the same:
cd c: cd flac ./configure make make install
You'll still getting some errors of type:
error: 'memcmp' was not declared in this scope
That is for some missing includes in the examples, but the library should be properly compiled.
Copy and paste.
This time we're not going to use MSYS but neither Cmake-GUI, instead we're going to use only the windows console (cmd.exe), so you need to type:
cd c:/dumb mingw32-make gcc make/dumbask.c -o make/dumbask.exe make\config.bat Would you like to compile DUMB for DJGPP or MinGW (D/M)?
Press the letter "M".
Would you like support for Allegro (Y/N)
Since the DUMB installer "magically" knows where to install the binaries and always chooses the "C:/mignw" directory, we're not going to install it (by not typing mingw32-make install) but just build it. So, inside the "C:/dumb" directory you should be able to find the "include" and "lib" folders, put them inside a "dumb" folder and paste it in the "deps" folder. Inside the "lib" folder the installation process has created a mingw folder which you should delete, otherwise Allegro won't be able to find the binaries, so extract the binaries, and put them inside the "lib" folder directly.
Download the directX9-bin zip file, which contains a collection of only the necessary DirectX libraries and includes to build Allegro 5.1, you could also use the original DirectX 9 SDK but its size is 120 MB more or less.
This folder needs to be placed in two folders: the "deps" folder and inside the MinGW folder. This is because OpenAL make uses of the DirectSound library and there is no way to tell OpenAL (which we're going to build latter on) where to find the binaries using the Cmake-GUI program, so we can't tell it that DirectSound (part of DirectX) is already compiled and installed inside the "deps" folder, but instead OpenAL is looking only in the paths set in the environment variables.
Obviously you could add the "directx9-bin" to the "path" environment variable, but the idea is to get a "deps" folder with all the dependencies for future uses, so we're going to put it in both places.
You would need to install the CG Toolkit too, which original size is 14 MB more or less. But this version is less than 4MB since as with DirectX9-bin only contains a collection of the necessary files to compile Allegro 5.1.
OpenAL also uses Cmake so do the same than with zlib. Remember to change the installation prefix path to the "deps" folder and in this case you can select a "release" build type. Delete the extra "AL" folder that the installation process creates in the "include" folder, and place the files directly inside the "include" folder.
Next FreeType, using MSYS you do the same:
cd c: cd freetype ./configure make < -- this one says nothing to do, but do it anyway :), just in case. make install
Remember to put it into a folder and past it into the "deps" folder.
PhysFS uses Cmake, but in the configuration process you need to tell it where to find Zlib like this:
Allegro 5.1 Configuration
Checking everything is correct
Well, if you have reach this point without problems then congratulations!. Let me show you what you should have (more or less) in your Cmake-GUI output:
The C compiler identification is GNU The CXX compiler identification is GNU Check for working C compiler: C:/MinGW/bin/gcc.exe Check for working C compiler: C:/MinGW/bin/gcc.exe -- works Detecting C compiler ABI info Detecting C compiler ABI info - done Check for working CXX compiler: C:/MinGW/bin/g++.exe Check for working CXX compiler: C:/MinGW/bin/g++.exe -- works Detecting CXX compiler ABI info Detecting CXX compiler ABI info - done Adding C:/a5.1/deps/Directx9 to CMAKE_FIND_ROOT_PATH Adding C:/a5.1/deps/dumb to CMAKE_FIND_ROOT_PATH Adding C:/a5.1/deps/flac to CMAKE_FIND_ROOT_PATH Adding C:/a5.1/deps/FreeType to CMAKE_FIND_ROOT_PATH Adding C:/a5.1/deps/ogg to CMAKE_FIND_ROOT_PATH Adding C:/a5.1/deps/OpenAL to CMAKE_FIND_ROOT_PATH Adding C:/a5.1/deps/physfs to CMAKE_FIND_ROOT_PATH Adding C:/a5.1/deps/vorbis to CMAKE_FIND_ROOT_PATH Adding C:/a5.1/deps/zlib to CMAKE_FIND_ROOT_PATH Using MINGDIR: C:/mingw Performing Test HAVE_DM_POSITION Performing Test HAVE_DM_POSITION - Success Allowing GCC to use SSE instructions Check if the system is big endian Searching 16 bit integer Looking for sys/types.h Looking for sys/types.h - found Looking for stdint.h Looking for stdint.h - found Looking for stddef.h Looking for stddef.h - found Check size of unsigned short Check size of unsigned short - done Using unsigned short Check if the system is big endian - little endian Looking for include files ALLEGRO_HAVE_DIRENT_H Looking for include files ALLEGRO_HAVE_DIRENT_H - found Looking for include files ALLEGRO_HAVE_INTTYPES_H Looking for include files ALLEGRO_HAVE_INTTYPES_H - found Looking for include files ALLEGRO_HAVE_LINUX_JOYSTICK_H Looking for include files ALLEGRO_HAVE_LINUX_JOYSTICK_H - not found. Looking for include files ALLEGRO_HAVE_STDBOOL_H Looking for include files ALLEGRO_HAVE_STDBOOL_H - found Looking for include files ALLEGRO_HAVE_STDINT_H Looking for include files ALLEGRO_HAVE_STDINT_H - found Looking for include files ALLEGRO_HAVE_SYS_IO_H Looking for include files ALLEGRO_HAVE_SYS_IO_H - not found. Looking for include files ALLEGRO_HAVE_SYS_STAT_H Looking for include files ALLEGRO_HAVE_SYS_STAT_H - found Looking for include files ALLEGRO_HAVE_SYS_TIME_H Looking for include files ALLEGRO_HAVE_SYS_TIME_H - found Looking for include files ALLEGRO_HAVE_TIME_H Looking for include files ALLEGRO_HAVE_TIME_H - found Looking for include files ALLEGRO_HAVE_SYS_UTSNAME_H Looking for include files ALLEGRO_HAVE_SYS_UTSNAME_H - not found. Looking for include files ALLEGRO_HAVE_SYS_TYPES_H Looking for include files ALLEGRO_HAVE_SYS_TYPES_H - found Looking for include files ALLEGRO_HAVE_SOUNDCARD_H Looking for include files ALLEGRO_HAVE_SOUNDCARD_H - not found. Looking for include files ALLEGRO_HAVE_SYS_SOUNDCARD_H Looking for include files ALLEGRO_HAVE_SYS_SOUNDCARD_H - not found. Looking for include files ALLEGRO_HAVE_MACHINE_SOUNDCARD_H Looking for include files ALLEGRO_HAVE_MACHINE_SOUNDCARD_H - not found. Looking for include files ALLEGRO_HAVE_LINUX_SOUNDCARD_H Looking for include files ALLEGRO_HAVE_LINUX_SOUNDCARD_H - not found. Looking for include files ALLEGRO_HAVE_OSATOMIC_H Looking for include files ALLEGRO_HAVE_OSATOMIC_H - not found. Looking for include files ALLEGRO_HAVE_SYS_INOTIFY_H Looking for include files ALLEGRO_HAVE_SYS_INOTIFY_H - not found. Looking for include files ALLEGRO_HAVE_SYS_TIMERFD_H Looking for include files ALLEGRO_HAVE_SYS_TIMERFD_H - not found. Looking for getexecname Looking for getexecname - not found Looking for mkstemp Looking for mkstemp - not found Looking for mmap Looking for mmap - not found Looking for mprotect Looking for mprotect - found Looking for sched_yield Looking for sched_yield - not found Looking for sysconf Looking for sysconf - not found Looking for fseeko Looking for fseeko - not found Looking for ftello Looking for ftello - not found Check size of _Bool Check size of _Bool - done Performing Test ALLEGRO_HAVE_PROCFS_ARGCV Performing Test ALLEGRO_HAVE_PROCFS_ARGCV - Failed Performing Test ALLEGRO_HAVE_SV_PROCFS_H Performing Test ALLEGRO_HAVE_SV_PROCFS_H - Failed Performing Test ALLEGRO_HAVE_VA_COPY Performing Test ALLEGRO_HAVE_VA_COPY - Success Check if constructors are supported - yes Found DINPUT: C:/a5.1/deps/Directx9/Include Found D3D9: C:/a5.1/deps/Directx9/Include Found GDIPLUS: C:/a5.1/deps/Directx9/include Performing Test SUPPORT_GDIPLUS Performing Test SUPPORT_GDIPLUS - Success Found DSOUND: C:/a5.1/deps/Directx9/Include Found OpenAL: C:/a5.1/deps/OpenAL/lib/libOpenAL32.dll.a Found FLAC: C:/a5.1/deps/flac/include Performing Test FLAC_COMPILES Performing Test FLAC_COMPILES - Success WARNING: Dynamic loading will be disabled for FLAC as static library was found: C:/a5.1/deps/flac/lib/libFLAC.a Found DUMB: C:/a5.1/deps/dumb/include Performing Test DUMB_COMPILES Performing Test DUMB_COMPILES - Success WARNING: Dynamic loading will be disabled for DUMB as static library was found: C:/a5.1/deps/dumb/lib/libdumb.a Found VORBIS: C:/a5.1/deps/ogg/include Performing Test VORBIS_COMPILES Performing Test VORBIS_COMPILES - Success DLL name for C:/a5.1/deps/vorbis/lib/libvorbisfile.dll.a: libvorbisfile-3.dll Found Freetype: C:/a5.1/deps/FreeType/lib/libfreetype.dll.a Found ZLIB: C:/a5.1/deps/zlib/include (found version "1.2.5") Found PhysFS: C:/a5.1/deps/physfs/lib/libphysfs.dll.a Found PHYSFS: C:/a5.1/deps/physfs/lib/libphysfs.dll.a Performing Test PHYSFS_IMPLICIT_ZLIB Performing Test PHYSFS_IMPLICIT_ZLIB - Success Configuring done
And in your "deps" folder you should have something like this:
Debug and Release Mode
Before pressing the "Generate" button, you should configure some basics points. If you want to create a debug version of the Allegro libraries which automatically generate an "Allegro.log" file when programming your applications, you've to write "debug" in the "CMAKE_BUILD_TYPE" section:
Otherwise you could write "release" and the "Allegro.log" file wont be generated.
You can also choose if you want Static or Dynamic libraries (Static and Dynamic Link), by changing the "SHARE" variable.
Unchecking it will generate static libraries.
After that, in the "CMAKE_INSTALL_PREFIX" you can select where the binaries are going to be installed.
Since in this case we're doing a "static / release" building make sure you're linking to the static binaries of each libraries, which should end in ".a" or ".lib" and not in ".dll".
You have also a "WANT" section which allows you to select what to build: examples, demos, Docs etc.
So finally you should have something like this:
So what it left is just to press the "Generate" button and build Allegro 5.1 using the console!.
cd c:/a5.1-ready mingw32-make mingw32-make install
And that that's it. Allegro is built an ready to use. You should like always get two folders ("include" and "lib") and in the lib folder you should have these files:
liballegro_acodec_static.a liballegro_audio_static.a liballegro_color_static.a liballegro_dialog_static.a liballegro_font_static.a liballegro_image_static.a liballegro_main_static.a liballegro_memfile_static.a liballegro_physfs_static.a liballegro_primitives_static.a liballegro_shader_static.a liballegro_ttf_static.a liballegro_static.a
With Allegro 5.1 there is a new addon: "Shader addon", and with this type of build you also need to link to "OpenAL.a" besides all the other dependencies (all the files are inside you "deps" folder) when doing static link. Follow the Windows Vista, Code::Blocks 10.05 and Allegro 5 Static link section to learn how to set up a static link.