Images in this page are not updated, but most of them are just difference on version.
-
Install Allegro5 by following the official guide
-
To compile
cd Final_Codes make ./pacman
-
To clean object files and executable files
cd Final_Codes make clean
This year we highly recommend you use Visual Studio 2022 on Windows.
-
After installation, just download the release pack we provided for you.
-
Linking Allegro5 to Code::Blocks by yourself.
-
Download allegro-x86_64-w64-mingw32-gcc-8.2.1-posix-seh-static-5.2.5.1.zip
-
Un-zip the file and move it to your C drive. The full path should be like:
C:\allegro-x86_64-w64-mingw32-gcc-8.2.1-posix-seh-static-5.2.5.1\allegro
-
Create a new project
- Open Code::Blocks
File > New > Project...
- Click
Console application
andGo
. - Click
Next
, SelectC
andNext
.
- Click
- Enter title
allegro-test
,Next
,Finish
.
-
Set up project
-
Project > Build options...
-
[Optional]
InCompiler settings > Compiler flags
, you can check the-std=c99
flag if you want to use C99 features. -
Set up include directories
Make sure that the focus on the left side is the project name (
allegro-test
). SelectSearch directories > Compiler
and clickAdd
, paste the following path into the textbox and clickOK
.C:\allegro-x86_64-w64-mingw32-gcc-8.2.1-posix-seh-static-5.2.5.1\allegro\include\
-
Set up library directories
Make sure that the focus on the left side is the project name (
allegro-test
). SelectSearch directories > Linker
and clickAdd
, paste the following path into the textbox and clickOK
.C:\allegro-x86_64-w64-mingw32-gcc-8.2.1-posix-seh-static-5.2.5.1\allegro\lib\
-
Select
Debug
at the left side. SelectLinker settings
and clickAdd
, paste the following path into the textbox and clickOK
.C:\allegro-x86_64-w64-mingw32-gcc-8.2.1-posix-seh-static-5.2.5.1\allegro\lib\liballegro_monolith-debug.dll.a
-
Select
Release
at the left side. SelectLinker settings
and clickAdd
, paste the following path into the textbox and clickOK
.C:\allegro-x86_64-w64-mingw32-gcc-8.2.1-posix-seh-static-5.2.5.1\allegro\lib\liballegro_monolith.dll.a
-
Click
OK
.
-
-
Test the library
-
Copy the code below and paste to your
main.c
at the left sideProjects > Workspace > [ProjectName](allegro-test) > Sources > main.c
:#include <allegro5/allegro.h> #include <allegro5/allegro_font.h> int main(int argc, char **argv) { al_init(); al_init_font_addon(); ALLEGRO_DISPLAY* display = al_create_display(800, 600); ALLEGRO_FONT* font = al_create_builtin_font(); al_clear_to_color(al_map_rgb(0, 0, 0)); al_draw_text(font, al_map_rgb(255, 255, 255), 400, 300, ALLEGRO_ALIGN_CENTER, "Welcome to Allegro!"); al_flip_display(); al_rest(5.0); al_destroy_font(font); al_destroy_display(display); return 0; }
-
Press
F9
to compile and run. -
If it pops a
dll not found
error, copy the file below to[Project Directory]\bin\Debug\
C:\allegro-x86_64-w64-mingw32-gcc-8.2.1-posix-seh-static-5.2.5.1\allegro\bin\allegro_monolith-debug-5.2.dll
-
Press
F9
and the window will pop out saying "Welcome to Allegro!".
-
-
-
Install Allegro5 by following Official Guide(English)
-
To compile
cd Final_Codes make ./pacman
-
To clean object files and executable files
cd Final_Codes make clean
- Video Tutorial(Chinese).
Video Tutorial(Chinese).(Old macOS 10.X)
-
Install allegro by following Official Guide(English)
-
Open
XCode
, Create a newMacOS
project, chooseApp
. -
Click your project at the left side, go to
Building Settings > All
and searchSearch Paths
. -
Under
Search Paths
, setHeader Search Paths
to/usr/local/include
and/opt/homebrew/Cellar/allegro/5.2.7.0/include
(For newhomebrew
case) and setLibrary Search Paths
to/usr/local/lib
and/opt/homebrew/Cellar/allegro/5.2.7.0/lib
.- Both use
non-recursive
.
- Both use
-
Open terminal and type:
cd /usr/local/Cellar # or /opt/homebrew/Cellar/allegro open .
-
Navigate to
allegro/5.2.7.0/lib/
-
Sort by
Modified date
and select all files that is modified today. (don't need to select thepkgconfig
folder) -
Go back to XCode and click
General
. -
Drag the selected files into the
Frameworks, Libraries, and Embedded Content
.
-
Create
main.c
(File > New > File... > C file
), uncheckAlso create a header file
.-
Paste the code below to the file.
#include <allegro5/allegro.h> #include <allegro5/allegro_font.h> int main(int argc, char **argv) { al_init(); al_init_font_addon(); ALLEGRO_DISPLAY* display = al_create_display(800, 600); ALLEGRO_FONT* font = al_create_builtin_font(); al_clear_to_color(al_map_rgb(0, 0, 0)); al_draw_text(font, al_map_rgb(255, 255, 255), 400, 300, ALLEGRO_ALIGN_CENTER, "Welcome to Allegro!"); al_flip_display(); al_rest(5.0); al_destroy_font(font); al_destroy_display(display); return 0; }
-
-
Click the
Play
button.
(For Code::Blocks, Dev-C++, XCode) If you link Allegro5 libraries by yourself, that is, using a pre-built Allegro5 binaries to setup your project (For Code::Blocks, Dev-C++, XCode, we do in this way), please download the matched (closest) version of Allegro5 binaries to your gcc(compiler) version. (You can find them on Allegro5 Github page.
For example, if you're using Code::Blocks v20.03 shipped with minGW compiler, your gcc version would be 8.1.0. In this case, please download pre-built Allegro5 for gcc 8.2.1.
To check your gcc version, open command window, go to the folder where you installed minGW. (".../CodeBlocks/MinGW/bin" for Code::Blocks) And type "gcc --version".
Then go the the Allegro5 github page to find the matched version of pre-built binaries.
The version of Allegro5 binaries may not be the matched one for your gcc(compiler) in the following examples.
Inspect your processor and download the corresponding library:
- allegro-i686-w64-mingw32-gcc-7.2.0-posix-dwarf-static-5.2.4.1.zip
- allegro-x86_64-w64-mingw32-gcc-7.2.0-posix-seh-static-5.2.4.1.zip
- allegro-mingw-gcc6.2.0-x86-static-5.2.2.zip
- allegro-mingw-gcc6.2.0-x64-static-5.2.2.zip
Unzip the file and put it under C drive.
Create main.c
and paste the code below:
#include <allegro5/allegro.h>
#include <allegro5/allegro_font.h>
int main(int argc, char **argv) {
al_init();
al_init_font_addon();
ALLEGRO_DISPLAY* display = al_create_display(800, 600);
ALLEGRO_FONT* font = al_create_builtin_font();
al_clear_to_color(al_map_rgb(0, 0, 0));
al_draw_text(font, al_map_rgb(255, 255, 255), 400, 300, ALLEGRO_ALIGN_CENTER, "Welcome to Allegro!");
al_flip_display();
al_rest(5.0);
al_destroy_font(font);
al_destroy_display(display);
return 0;
}
Type the command that matches your download.
gcc -Wall -g -IC:\allegro-i686-w64-mingw32-gcc-7.2.0-posix-dwarf-static-5.2.4.1\allegro\include main.c -LC:\allegro-i686-w64-mingw32-gcc-7.2.0-posix-dwarf-static-5.2.4.1\allegro\lib -lallegro_monolith.dll
gcc -Wall -g -IC:\allegro-x86_64-w64-mingw32-gcc-7.2.0-posix-seh-static-5.2.4.1\allegro\include main.c -LC:\allegro-x86_64-w64-mingw32-gcc-7.2.0-posix-seh-static-5.2.4.1\allegro\lib -lallegro_monolith.dll
gcc -Wall -g -IC:\allegro-mingw-gcc6.2.0-x86-static-5.2.2\allegro\include main.c -LC:\allegro-mingw-gcc6.2.0-x86-static-5.2.2\allegro\lib -lallegro_monolith.dll
gcc -Wall -g -IC:\allegro-mingw-gcc6.2.0-x64-static-5.2.2\allegro\include main.c -LC:\allegro-mingw-gcc6.2.0-x64-static-5.2.2\allegro\lib -lallegro_monolith.dll