ACES

Computer Science

Development Environment: MinGW + Code::Blocks + Allegro


Monday, July 10, 2006

This is a how-to document on installing and configuring a build environment with an IDE for Allegro. The following instructions are tailored for WinXP.

Installing and configuring MinGW

  1. Download the latest MinGW installer: http://prdownloads.sourceforge.net/mingw/MinGW-5.0.2.exe?download
  2. Run the installer, select the mirror closest to your location, and select Download as needed and install.
  3. Select "Current" on the next screen and hit next.
  4. Run a full installation. (A few selections are not necessary on this screen, but I tend to use everything so I select it all). Ada, Java, Objective C, and g77 may not be needed for your particular use.
  5. On the next screen, make the path be default (C:\MinGW) and accept the rest of the prompts until the install is finished.
  6. Open the System Environment Variables by hitting <Windows Key> + Pause/Break, select the Advanced tab, and hitting the Environment Variables button.
  7. Once the Env. Vars open up, add a new user environment variable named MINGDIR. Make the value be the same as you picked for step "e". In this case it would be C:\MinGW. (You will also have to add C:\MinGW\bin to the PATH to make the compiler to work)
  8. Goto the command prompt and type gcc -v to test the installation. If it outputs version information associated with your version of compiler, you are ready to go onto the next stage.

Installing and compiling Allegro

  1. Download the latest version of Allegro: http://prdownloads.sourceforge.net/alleg/all420.zip?download and unzip this file into the main directory of your MinGW installation. (C:\MinGW)
  2. Download the DirectX 7 SDK http://alleg.sourceforge.net/files/dx70_mgw.zip or the DirectX 8 SDK http://alleg.sourceforge.net/files/dx80_mgw.zip and extract it into the main directory of your MinGW installation (C:\MinGW).
  3. Open a command prompt and cd to your Allegro directory (C:\MinGW\allegro)
  4. Run cmd> fix.bat mingw32 from this directory
  5. Run cmd> mingw32-make (it may be easier to rename C:\MinGW\bin\mingw32-make.exe to make.exe and substitute throughout this document)
  6. (If you want to static link, you will have to build allegro to do that): Run cmd> mingw32-make STATICLINK=1
  7. Finally run cmd> mingw32-make install
  8. If it did not output errors, you are ready to go onto the next stage.

Installing Code::Blocks, the IDE

  1. It is recommended to get a nightly build from here: http://forums.codeblocks.org/index.php?board=20.0
  2. This document is based on the July 10th, 2006 build: http://forums.codeblocks.org/index.php?topic=3515.0
  3. You will need three things: the unicode http://download.berlios.de/codeblocks/wxmsw26u_gcc_cb_wx2.6.3p2.7z ; the ansi http://download.berlios.de/codeblocks/wxmsw26_gcc_cb.7z ; and the IDE files http://download.berlios.de/codeblocks/CB_20060710_rev2729_win32.7z
  4. Extract these to C:\CodeBlocks or the folder of your choice with 7-zip http://www.7-zip.org/
  5. Right-click on the executable and create a shortcut to the desktop.
  6. Run the shortcut and verify that it works.

Allegro Templates

  1. Download the file attachment and extract into the %APPDATA%/codeblocks/UserTemplates directory.
  2. To use the static linking capability of Allegro, choose the User Template "Allegro Static Link".
  3. To use the default dynamic linking (the application needs the allegro dll) capability of Allegro, choose the User Template "Allegro Dynamic Link".
  4. The templates only include the linking information, so you will need to add/write source files.
  5. Just to check, try this sample code (as shown in the Allegro documentation):
#include <allegro.h>
int main()
{
allegro_init();
allegro_message("Hello World!");
return 0;
}
END_OF_MAIN()