Allegro.cc - Online Community

Allegro.cc Forums » Installation, Setup & Configuration » Guide to install Allegro 5 from source on Windows with MinGW

This thread is locked; no one can reply to it. rss feed Print
 1   2 
Guide to install Allegro 5 from source on Windows with MinGW
SiegeLord
Member #7,827
October 2006
avatar

I decided to document the process I follow to build Allegro5 from scratch on Windows and I put it up on the wiki!

It comes with a set of patched sources for some of the dependencies necessary for Allegro. Those following the guide install MinGW, MSYS and git (send me a $20 if you want me to do a MSVC writeup) and basically all the Allegro dependencies (some minor ones used only in one example are missing).

I'd like some comments (and if somebody tries it, all the better):

http://wiki.allegro.cc/index.php?title=Install_Allegro5_From_Git/Windows

"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

Peter Wang
Member #23
April 2000

You might mention using GDI+ which would cut out the zlib/libpng/libjpeg dependencies.

Also, it still feels a bit risky using /dev :)

Erin Maus
Member #7,537
July 2006
avatar

Sounds good to me. Same procedure I use when I compile all the libraries from scratch. I love the straightforwardness.

---
ItsyRealm, a quirky 2D/3D RPG where you fight, skill, and explore in a medieval world with horrors unimaginable.
they / she

Matthew Leverton
Supreme Loser
January 1999
avatar

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

I'd say it's a good guide, all up to the part about compiling allegro. At that point I think it lacks details about cmake options available to build allegro with. I hate having to grep -r -E -I -n "WANT" to see the options. But what I'm really after is a short bit on -DCMAKE_BUILD_TYPE=[Debug Release RelWithDebInfo Profiling?]. And yeah, MSYS makes building those libraries easy even if ./configure takes forever. ;) What's it take to write an autoconf script anyway?

Edit-
Oh, and maybe a bit about deleting CMakeCache.txt and / or the build directory.

SiegeLord
Member #7,827
October 2006
avatar

Yikes! I'll have to change it (although I've never had issues with 'dev').

And yeah, MSYS makes building those libraries easy even if ./configure takes forever. ;) What's it take to write an autoconf script anyway?

The real time saver that this guide provides is that it figures out which libraries are compiled using MSYS and which can handle the command prompt. In fact many libraries claim to support non-MSYS builds, but in practice fail to build... since MSYS comes with MinGW I decided to just use MSYS as it is ultimately simpler (even MSYS builds are broken in a few places, hence the patched up sources).

And yes... I hate autotools... I really appreciate libPNG and libZlib coming with CMake build systems.

EDIT:

You might mention using GDI+ which would cut out the zlib/libpng/libjpeg dependencies.

I don't know if GDI+ works with MinGW... at least, I have no experience using it.

"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

Arthur Kalliokoski
Second in Command
February 2005
avatar

I tried doing what the guide said, and trying to run C:/mingw/msys/1.0/msys.bat as administrator brings up a command window (or at least a black box), but a prompt never appears. Trying to do the commands listed on the webpage as a normal user eventually failed, due to lack of permissions, I guess.

They all watch too much MSNBC... they get ideas.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

SiegeLord
Member #7,827
October 2006
avatar

I tried doing what the guide said, and trying to run C:/mingw/msys/1.0/msys.bat as administrator brings up a command window (or at least a black box), but a prompt never appears.

What OS is this? And how do you run it as an administrator? I right-clicked it and selected "Run as Administrator" and it worked ok on Win 7.

Quote:

Trying to do the commands listed on the webpage as a normal user eventually failed, due to lack of permissions, I guess.

Yeah... the DXSDK installer sets screwy permissions on the files I need to patch.

"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

Trent Gamblin
Member #261
April 2000
avatar

Why are you patching DXSDK files oO?

SiegeLord
Member #7,827
October 2006
avatar

They use __null, a keyword in GCC.

EDIT: More precisely...

dsound.h that comes with DirectX SDK has a whole bunch of uses of __null. In a different file (which doesn't come with DirectX SDK, but I supply in the source pack) called sal.h has this line in it (amongs others):

#define __null

That wrecks havoc on GCC compiled code... e.g.

#include <stdio.h>
#define __null

int main()
{
   int* a = NULL;
}

test.cpp: In function 'int main()':
test.cpp:6:17: error: expected primary-expression before ';' token

"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

Trent Gamblin
Member #261
April 2000
avatar

I wonder why I've never run into that...

Arthur Kalliokoski
Second in Command
February 2005
avatar

SiegeLord said:

What OS is this? And how do you run it as an administrator?

Windows 7, at first I just right clicked a command prompt shortcut to run as admin, and ran msys from that, then I right clicked the batch file itself to run as admin.

They all watch too much MSNBC... they get ideas.

Vanneto
Member #8,643
May 2007

I took a few notes, don't know how many of these are specific to me but you might want to know anyway.

1. libpng did not compile without setting -DZLIB_INCLUDE_DIR C:\MinGW\include first
2. You don't explain that you must cd into the DUMB directory. You explicitly show it at every other example, just not at the DUMB one.
3. The fix.sh complained that -i is an invalid command line option. I had to remove __null manually.
4. When compiling Allegro, it can't find dinput.h. I have set its path using:

$ cmake .. -G "MinGW Makefiles" -DDINPUT_INCLUDE_DIR=c:\dxsdk\include -DD3DX9_INCLUDE_DIR=c:\dxsdk\include
$ cmake .. -DCMAKE_BUILD_TYPE=Release -DDINPUT_INCLUDE_DIR=c:\dxsdk\include -DD3DX9_INCLUDE_DIR=c:\dxsdk\include

And then I get:

D:\Build\allegro\allegro5\src\win\wjoydxnu.cpp:81:20: fatal error: dinput.h: No such file or directory
compilation terminated.
mingw32-make[2]: *** [CMakeFiles/allegro.dir/src/win/wjoydxnu.cpp.obj] Error 1
mingw32-make[1]: *** [CMakeFiles/allegro.dir/all] Error 2
mingw32-make: *** [all] Error 2

EDIT:

I think what was wrong that I didn't restart cmd.exe after installing the DirectX SDK. Its found it now and it compiled.

Woo!

In capitalist America bank robs you.

SiegeLord
Member #7,827
October 2006
avatar

Vanneto said:

1. libpng did not compile without setting -DZLIB_INCLUDE_DIR C:\MinGW\include first

That... shouldn't happen ???

Quote:

2. You don't explain that you must cd into the DUMB directory. You explicitly show it at every other example, just not at the DUMB one.

Whoops, fixed.

Quote:

3. The fix.sh complained that -i is an invalid command line option. I had to remove __null manually.

That's... also puzzling. Given this and Arthur's issues I'm going to have to rethink what to do with the DXSDK...

Quote:

4. When compiling Allegro, it can't find dinput.h. I have set its path using:

My bad, I explicitly say to install other stuff while the DXSDK is downloading, meaning that this will always happen... fixed.

Thanks for trying it!

"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

Schyfis
Member #9,752
May 2008
avatar

I tried it, here's my experience!

You should note on the page that there will be an error when you install the DirectX SDK if you already have the MSVC++ 2010 Runtime installed. Here's a link to the solution.
Also, for whatever reason, there was no option to change the installation path for me.

Running ./fix.sh doesn't work. Changing it to simply

fix.sh

solved the problem.

When I tried to enter the directory where the DX SDK was installed, I got the error:
sed: can't read C:develDXSDK/Include/dsound.h: No such file or directory
Changing the \ to \\ allowed it to run correctly.

When making zlib, it couldn't find fseeko. Not sure if that's a problem or not.

When you say to "launch the MSYS shell", this is confusing. It's installed under the name "MinGW Shell".

DUMB complains on the first mingw32-make command that my MINGDIR environment variable is not set. Doesn't seem to be a problem, though.

Ran into a critical error when making Allegro. It can't find a bunch of stuff.

C:\Users\Will>cd C:\devel

C:\devel>git clone git://git.code.sf.net/p/alleg/allegro Allegro5
Cloning into 'Allegro5'...
remote: Counting objects: 89814, done.
remote: Compressing objects: 100% (21361/21361), done.
remote: Total 89814 (delta 70793), reused 84613 (delta 66722)
Receiving objects: 100% (89814/89814), 25.97 MiB | 3.70 MiB/s, done.
Resolving deltas: 100% (70793/70793), done.

C:\devel>cd Allegro5

C:\devel\Allegro5>mkdir build

C:\devel\Allegro5>cd build

C:\devel\Allegro5\build>cmake .. -G "MinGW Makefiles"
-- The C compiler identification is GNU 4.6.2
-- The CXX compiler identification is GNU 4.6.2
-- 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
-- Guessed MinGW directory: C:/MinGW
-- Performing Test HAVE_DM_POSITION
-- Performing Test HAVE_DM_POSITION - Success
-- Could NOT find PkgConfig (missing:  PKG_CONFIG_EXECUTABLE)
-- 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 file dirent.h
-- Looking for include file dirent.h - found
-- Looking for include file inttypes.h
-- Looking for include file inttypes.h - found
-- Looking for include files sys/types.h, linux/joystick.h
-- Looking for include files sys/types.h, linux/joystick.h - not found
-- Looking for include file stdbool.h
-- Looking for include file stdbool.h - found
-- Looking for include file stdint.h
-- Looking for include file stdint.h - found
-- Looking for include file sys/io.h
-- Looking for include file sys/io.h - not found
-- Looking for include file sys/stat.h
-- Looking for include file sys/stat.h - found
-- Looking for include file sys/time.h
-- Looking for include file sys/time.h - found
-- Looking for include file time.h
-- Looking for include file time.h - found
-- Looking for include file sys/utsname.h
-- Looking for include file sys/utsname.h - not found
-- Looking for include file sys/types.h
-- Looking for include file sys/types.h - found
-- Looking for include file soundcard.h
-- Looking for include file soundcard.h - not found
-- Looking for include file sys/soundcard.h
-- Looking for include file sys/soundcard.h - not found
-- Looking for include file machine/soundcard.h
-- Looking for include file machine/soundcard.h - not found
-- Looking for include file linux/soundcard.h
-- Looking for include file linux/soundcard.h - not found
-- Looking for include file libkern/OSAtomic.h
-- Looking for include file libkern/OSAtomic.h - not found
-- Looking for include file sys/inotify.h
-- Looking for include file sys/inotify.h - not found
-- Looking for include file sys/timerfd.h
-- Looking for include file 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
-- Found OpenGL: opengl32
-- Could NOT find DINPUT (missing:  DINPUT_INCLUDE_DIR)
CMake Error at CMakeLists.txt:633 (message):
  Windows port requires DirectInput (not found).


-- Configuring incomplete, errors occurred!

SiegeLord said:

My bad, I explicitly say to install other stuff while the DXSDK is downloading, meaning that this will always happen... fixed.

What should I do differently? I was pretty sure I followed the directions correctly, after you fixed it...

________________________________________________________________________________________________________
[freedwill.us]
[unTied Games]

Vanneto
Member #8,643
May 2007

Schyfis: restarting cmd.exe worked for me.

Oh, and fix.sh doesn't work if you put in a path with spaces, like the default location: C:\Program Files (x86)\Microsoft DirectX SDK\Include.

In capitalist America bank robs you.

SiegeLord
Member #7,827
October 2006
avatar

I modified the instructions/sourcepack (and sent a patch to Allegro) so that you no longer need to patch DirectX SDK to get it working (you will need to manually patch Allegro if you're not building 5.1 though).

Schyfis said:

You should note on the page that there will be an error when you install the DirectX SDK if you already have the MSVC++ 2010 Runtime installed. Here's a link to the solution. [support.microsoft.com]

Yes, I should mention it... although I thought it didn't really matter. It seemed to install anyway for me?

Quote:

Also, for whatever reason, there was no option to change the installation path for me.

I don't know what causes that (it happened to me once too).

Quote:

When making zlib, it couldn't find fseeko. Not sure if that's a problem or not.

That's fine, there's always innocuous stuff that CMake doesn't find.

Quote:

When you say to "launch the MSYS shell", this is confusing. It's installed under the name "MinGW Shell".

I didn't even know it made a Start menu folder! I'll modify the starting instructions to mention that alternative.

Quote:

DUMB complains on the first mingw32-make command that my MINGDIR environment variable is not set. Doesn't seem to be a problem, though.

That's fine too (we set it when it matters in the second step). I've modified the instructions to avoid having this error show up though.

Quote:

What should I do differently? I was pretty sure I followed the directions correctly, after you fixed it...

After you install the DirectX SDK, you should start a new command prompt, and it should work then... in your case, try this:

cd C:\devel\Allegro5\build
del CMakeCache.txt
cmake .. -G "MinGW Makefiles"

"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

Schyfis
Member #9,752
May 2008
avatar

SiegeLord said:

After you install the DirectX SDK, you should start a new command prompt, and it should work then... in your case, try this:

cd C:\devel\Allegro5\build
del CMakeCache.txt
cmake .. -G "MinGW Makefiles"

Same problem, it stops at "Could NOT find DINPUT (missing: DINPUT_INCLUDE_DIR)".
The DXSDK is located in C:\devel\DXSDK, and it has the subfolders Include, Lib, and so on. Is that where everything should be?

________________________________________________________________________________________________________
[freedwill.us]
[unTied Games]

SiegeLord
Member #7,827
October 2006
avatar

That is really puzzling, CMake should be able to find it by itself... it looks for the DXSDK_DIR which is set by the installer for DirectX SDK. I'll have to investigate this myself... for now, do this then:

cmake .. -G "MinGW Makefiles" -DDINPUT_INCLUDE_DIR=c:\dxsdk\include -DD3DX9_INCLUDE_DIR=c:\dxsdk\include

"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

Schyfis
Member #9,752
May 2008
avatar

Success! Here's my output. Now all it needs is audio.

C:\devel\Allegro5\build>cmake .. -G "MinGW Makefiles" -DDINPUT_INCLUDE_DIR=C:\DX
SDK\Include -DD3DX9_INCLUDE_DIR=C:\DXSDK\Include
-- Guessed MinGW directory: C:/MinGW
-- Could NOT find PkgConfig (missing:  PKG_CONFIG_EXECUTABLE)
-- Found D3D9: C:/MinGW/include
-- Found GDIPLUS: C:/MinGW/include
-- Performing Test SUPPORT_GDIPLUS
-- Performing Test SUPPORT_GDIPLUS - Success
-- Could NOT find DSOUND (missing:  DSOUND_INCLUDE_DIR)
-- Could NOT find OpenAL (missing:  OPENAL_LIBRARY OPENAL_INCLUDE_DIR)
-- Could NOT find OPENSL (missing:  OPENSL_INCLUDE_DIR OPENSL_LIBRARY)
WARNING: allegro_audio wanted but no supported backend found
-- Found Freetype: C:/MinGW/lib/libfreetype.dll.a (found version "2.4.12")
-- Found ZLIB: C:/MinGW/lib/libzlib.dll.a (found version "1.2.8")
-- Found PhysFS: C:/MinGW/lib/libphysfs.dll.a
-- Found PHYSFS: C:/MinGW/lib/libphysfs.dll.a
-- Performing Test PHYSFS_IMPLICIT_ZLIB
-- Performing Test PHYSFS_IMPLICIT_ZLIB - Success
-- Found OGG: C:/MinGW/include
-- Found THEORA: C:/MinGW/include
-- Found VORBIS: C:/MinGW/include
-- Not building Cosmic Protector
-- Not building SPEED
-- Not building skater demo
-- Not building ex_video
-- Not building ex_acodec
-- Not building ex_acodec_multi
-- Not building ex_audio_chain
-- Not building ex_audio_props
-- Not building ex_audio_simple
-- Not building ex_audio_timer
-- Not building ex_haiku
-- Not building ex_kcm_direct
-- Not building ex_mixer_chain
-- Not building ex_mixer_pp
-- Not building ex_record
-- Not building ex_record_name
-- Not building ex_resample_test
-- Not building ex_saw
-- Not building ex_stream_file
-- Not building ex_stream_seek
-- Not building ex_synth
-- Configuring done
-- Generating done
-- Build files have been written to: C:/devel/Allegro5/build

Try 2: I tried to specify DSOUND_INCLUDE_DIR, but got a slightly cryptic error.

C:\devel\Allegro5\build>cmake .. -G "MinGW Makefiles" -DDINPUT_INCLUDE_DIR=C:\DX
SDK\Include -DD3DX9_INCLUDE_DIR=C:\DXSDK\Include -DSOUND_INCLUDE_DIR=C:\DXSDK\In
clude
-- Guessed MinGW directory: C:/MinGW
-- Could NOT find PkgConfig (missing:  PKG_CONFIG_EXECUTABLE)
-- Could NOT find DSOUND (missing:  DSOUND_INCLUDE_DIR)
-- Could NOT find OpenAL (missing:  OPENAL_LIBRARY OPENAL_INCLUDE_DIR)
-- Could NOT find OPENSL (missing:  OPENSL_INCLUDE_DIR OPENSL_LIBRARY)
WARNING: allegro_audio wanted but no supported backend found
...
CMake Warning:
  Manually-specified variables were not used by the project:

    SOUND_INCLUDE_DIR

Try 3: I added another D to DSOUND_INCLUDE_DIR.

C:\devel\Allegro5\build>cmake .. -G "MinGW Makefiles" -DDINPUT_INCLUDE_DIR=C:\DX
SDK\Include -DD3DX9_INCLUDE_DIR=C:\DXSDK\Include -DDSOUND_INCLUDE_DIR=C:\DXSDK\I
nclude
-- Guessed MinGW directory: C:/MinGW
-- Could NOT find PkgConfig (missing:  PKG_CONFIG_EXECUTABLE)
-- Could NOT find OpenAL (missing:  OPENAL_LIBRARY OPENAL_INCLUDE_DIR)
-- Could NOT find OPENSL (missing:  OPENSL_INCLUDE_DIR OPENSL_LIBRARY)
-- Found FLAC: C:/MinGW/include
-- Performing Test FLAC_COMPILES
-- Performing Test FLAC_COMPILES - Success
WARNING: Dynamic loading will be disabled for FLAC as static library was found:
C:/MinGW/lib/libFLAC.a
-- Found DUMB: C:/MinGW/include
-- Performing Test DUMB_COMPILES
-- Performing Test DUMB_COMPILES - Success
WARNING: Dynamic loading will be disabled for DUMB as static library was found:
C:/MinGW/lib/libdumb.a
-- Performing Test VORBIS_COMPILES
-- Performing Test VORBIS_COMPILES - Success
-- DLL name for C:/MinGW/lib/libvorbisfile.dll.a: libvorbisfile-3.dll
-- Configuring done
-- Generating done
-- Build files have been written to: C:/devel/Allegro5/build

I think it's complete! ;D
Thanks for the guide, SiegeLord! Now to figure out how to get this to work with Android...

Edit:
Spoke a little too soon, it had a fatal error while looking for dinput.h. Same error Vanneto had... Except I've restarted my cmd window multiple times already.

________________________________________________________________________________________________________
[freedwill.us]
[unTied Games]

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Trent Gamblin
Member #261
April 2000
avatar

The problem with that package is when you link to d3dx9, you have to include the specific d3dx9.dll that included in the package. Distributing d3d/d3dx dlls is illegal, so for commercial games you must link to an official directx sdk and include the runtime (just the components you use optimally, it allows you to leave things out) with your game.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Stuff like that should probably be mentioned, along with the directions for the necessary alternative (but I mean on alleg.sourceforge.net, not just on the wiki).

and its slightly odd I've never run into that before - my proggies always work on other people's computers, even with the regular DX9+ installed. :/

Trent Gamblin
Member #261
April 2000
avatar

Yeah, ideally it would be. Or those packages could simply be removed for all I care.

 1   2 


Go to: