Windows, Code::Blocks and Allegro 5
To install Allegro with the pre-built binaries we need the Code::Blocks IDE, a MinGW installation, and Allegro binaries.
The compiler used to build allegro must be the same version as your compiler or else they will not work properly and you will get errors.
There are also unofficial builds which you can find here :
Note: While Code::Blocks comes with an embedded version of MinGW, it is recommended to use a standalone version such as the one linked above. This is for compatiblity reasons.
Allegro binaries and what to expect
Inside your binary distribution you should find three folders - \bin, \lib, and \include. \include is where all the allegro library headers are kept. \lib is where the archives that you link to are stored, and \bin is where the dynamic link libraries are kept. If you link dynamically you need these to be with your program at run time.
bin include lib
Configuring A New Project to use Allegro
Creating a New Project
- Open Code::Blocks
- In the menu, select File->New->Project
- Select "Empty Project" and then "Go"
- Enter a project title and a destination folder
- Make sure "Create Debug configuration" and "Create Release configuration" are both selected
Creating a new file and adding it to your project
- Select File > New > Empty File
- Press "yes" to add the file to the current project.
- Enter a name for the file and save it. As this example is using the c++ language, remember to end the file with ".cpp" instead of ".c".
- Select "Debug" and "Release" configurations.
Setting project Search Directories
Now you need to add the allegro\include directory from the binary distribution to your compiler search directory. Go to Project->Build Options and select your overall project in the upper left. Then select the search directories tab on the right and then the compiler tab underneath it.
After that, go to the linker search directory tab and add allegro\lib to your search path.
Next, you need to update your linker settings to make your project link properly to allegro.
Most distributions of allegro come with a monolith version. That is what we'll be using here :
Make sure you match the names you are using with the names of your distribution's libraries. Dynamic versions generally end in .dll.a and static versions generally end in -static.a. Select the debugging or release versions as appropriate.
When linking statically there are many more libraries that you need to link to.
Here is the full list of libraries :
-lallegro_monolith-debug-static -ljpeg -ldumb -lFLAC -lfreetype -lvorbisfile -lvorbis -logg -lphysfs -lpng16 -lzlibstatic -ldsound -lgdiplus -luuid -lkernel32 -lwinmm -lpsapi -lopengl32 -lglu32 -luser32 -lcomdlg32 -lgdi32 -lshell32 -lole32 -ladvapi32 -lws2_32 -lshlwapi -static-libstdc++ -static-libgcc
That just about covers it for MinGW, Code::Blocks and Allegro. You do need to make sure \mingw\bin is on your %PATH% environment variable when you compile from the command line.