Compiling for windows from Linux with mingw: allegro.h no such file or directory
dusthillresident

Hello,

I'm writing a game using Allegro 4.
It compiles and works well on linux with GCC.

I want to compile my game for windows so other people can play it.
I have mingw installed and I'm able to compile simple 'hello world' type programs with i686-w64-mingw32-gcc, but I can't compile any software that uses allegro, I get the error 'allegro.h not found'

What I've tried doing so far:
I downloaded the allegro-4.4.2 sourcecode and extracted it into a folder, and I tried these commands:

i686-w64-mingw32-gcc test.c -Iallegro-4.4.2/ -Lallegro-4.4.2/ -lalleg
i686-w64-mingw32-gcc test.c -Lallegro-4.4.2/ -lalleg
i686-w64-mingw32-gcc test.c -Iallegro-4.4.2/ -lalleg

They all gave me the 'allegro.h not found' error.

Then I tried changing to the allegro-4.4.2 directory and running this:

i686-w64-mingw32-gcc test.c -Iinclude/ -lalleg

This gave me a different error,

include/allegro/internal/alconfig.h:36:44: fatal error: allegro/platform/alplatf.h: No such file or directory

So just to see what would happen, I went and renamed alconfig.h.cmake to alconfig.h and then I got a screen full of messages like this:

include/allegro/platform/alplatf.h:1:2: error: invalid preprocessing directive #cmakedefine
 #cmakedefine ALLEGRO_BCC32

Anyway, what should I do? Does anyone here have experience building allegro programs for windows targets on Linux systems?

Edgar Reynaldo

You need more than the source code, and you need to point to -I allegro4.4.2/include for the headers. You need binaries, built yourself or by someone else with the exact same compiler.

dusthillresident

Thanks. How would I build the binaries?

Edgar Reynaldo

With cmake-gui, ccmake, or cmake and mingw32-i686-make or whatever.

dusthillresident

There doesn't seem to be a make command specifically for mingw32. How would I tell 'make' to compile using the mingw equivalent gcc and other mingw tools?

Edit:
I'm not sure this is going to work at all, so I'm installing the windows version of mingw on another computer that has windows 10. Hopefully I'll have more luck with that.

Edit: After a lot of trouble I got it to work.

Edgar Reynaldo

You have to install cmake, and make.

dusthillresident

After installing mingw in windows, I needed to install cmake. Then I worked out how to use cmakegui, I had to give it the paths to mingw's gcc and g++ commands.

Then compiling allegro4 failed because some files related to DirectX had slightly wrong variable/constant names for some reason, so I had to manually search & replace until it compiled.

Then I had to work out what command options I needed to give to gcc in order to make it compile my own game program. I eventually worked that out by looking at the CMakeList files for the example programs.

Edgar Reynaldo

I have binaries for Allegro 4.4.3 here :

https://www.allegro.cc/forums/thread/617127

Thread #617162. Printed from Allegro.cc