Allegro.cc - Online Community

Allegro.cc Forums » Installation, Setup & Configuration » How do you compile an allegro program on Windows usings MSYS2 and MinGW?

This thread is locked; no one can reply to it. rss feed Print
How do you compile an allegro program on Windows usings MSYS2 and MinGW?
iheartcoffee
Member #16,518
August 2016
avatar

I'm a total newbie to Allegro and I was wondering, how do you issue a compile command to compile a program using Allegro 5?

I do know how to compile using gcc.
gcc -static -pedantic -ansi -Wall hello.c -o hello.exe

but how do you issue a command to gcc to statically link Allegro 5 so that the DLLs don't need to be distributed with the program?
Thanks,
Sean

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Hello iheartcoffee,

Here are a few tips for compiling with gcc.

Some flags :

-I include/directory
-L link/directory
-lLIBNAME

You'll need to specify the include and linker search directories with -I and -L. Then you specify the link libraries with -l. To link with library libNAME.a you use -lNAME . The lib and .a are added automatically.

The full list of static libraries for allegro 5 is as follows :

-static 
-ljpeg 
-ldumb 
-lFLAC 
-ltheora
-lvorbisfile 
-lvorbis 
-logg 
-lphysfs 
-lfreetype 
-lpng16 
-lzlibstatic 
-ldsound
-lgdiplus 
-luuid 
-lkernel32 
-lwinmm 
-lpsapi 
-lopengl32 
-lglu32 
-luser32 
-lcomdlg32 
-lgdi32 
-lshell32 
-lole32 
-ladvapi32 
-lws2_32 
-lshlwapi 
-static-libstdc++ 
-static-libgcc

So first link to allegro :

-lallegro_monolith-static

and then the list above.

Your final command will look like this :

gcc -Wall -Wextra -Wshadow -pedantic -ansi -o Program.out -I c:\allegro\include main.c -L c:\allegro\lib -lallegro_monolith-static -static -ljpeg -ldumb -lFLAC  -ltheora -lvorbisfile -lvorbis -logg -lphysfs -lfreetype -lpng16 -lzlibstatic -ldsound -lgdiplus -luuid -lkernel32 -lwinmm -lpsapi -lopengl32 -lglu32 -luser32 -lcomdlg32 -lgdi32 -lshell32 -lole32 -ladvapi32 -lws2_32 -lshlwapi -static-libstdc++ -static-libgcc

ZoriaRPG
Member #16,714
July 2017
avatar

Hmm... I wasn't aware that you could build and not include an allegro lib of some kind with the binary.

Why do you need to make a build without a library file in your distribution?

I know that you can build Ag5 in monolithic, but your final binary still needs the mono-lib, even then.

If it's possible to build a binary where all of the allegro library is embedded in one file, it's a new one for me.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Niunio
Member #1,975
March 2002
avatar

Welcome to the future.

Future? It was the only way on DOS! ;D

-----------------
Current projects: Allegro.pas | MinGRo

Go to: