The Allegro Wiki is migrating to github at


From Allegro Wiki
Jump to: navigation, search
This article is a stub. Please help Allegro by expanding it.

Broom icon.png
This article or section is messy and needs some minor revision to bring it up to quality standards. Please help Allegro by editing it. When the article is formatted correctly, you may remove this tag.

TODO: Clean up and format the article. Perhaps add in some screen shots. (edit)

Setting up Allegro to work under Eclipse on Ubuntu

First, download the newest stable Allegro source, and if you don't have it, download the Eclipse SDK and the CDT add on. You can obtain Ecplise and CDT through Synaptic if you want. The best option is to download the Eclipse IDE for C/C++ Developers straight from the Eclipse website.

Next, extract the Allegro source to a folder and open a terminal window. Make the folder that has the Allegro source files the active folder. Run configure (./configure) if you'd like to be able to statically link Allegro add the --enable-static flag. After if finishes, run make to build the source. At the time of writing there is is A known make error . Then make install with super user privileges to install the Allegro library. If you don't have admin privileges, read the unix.txt document in the docs/build folder for more information.

Now, for using Allegro in a project with eclipse. I will go over having the library statically linked into the executable.

Create a new C++ project by clicking on File then the following: New, C++ Project, Enter a name for the project, Executable, Empty Project, Finish. Now, right click on your project in the C++ Projects Exlorer and click Properties. On the left navigation click on C/C++ Build then Settings. Under the Tool settings tab select Libraries under GCC C++ Linker. On the right you should see two lists for the options Libraries (-l) and Library search path (-L).

Screenshot showing the Allegro library setup in Eclipse

Open a terminal window and enter this command

allegro-config --static

You should get an output similar to this

-L/usr/local/lib -Wl,--export-dynamic -lalleg -lm -lXxf86vm -lXcursor -lXpm -lXext -lX11 -lpthread -ldl

In Eclipse, put the -L<path> part under Library search path (-L) by clicking the Add button. In this example, just copy /usr/local/lib. You are omiting the -L flag because Eclipse will automaticly add it during the build process.

Now go up to Libraries, and add all the listed libraries (i.e. -lalleg,-lm, etc.) under the Libraries (-l) by clicking the add button. Add each library on a new line. Only add the part after the -l (i.e. alleg not -lalleg). The order appears not to matter (not fully tested yet). See screen shot for more clarification.

Now that we have our libraries added, click on Miscellaneous under GCC C++ Compiler . You should see a text box that is labeled for Linker flags. In this box add any extra flags given by allegro-config exactly. In the case above, I would put -Wl,--export-dynamic.

Now add your source files as needed and you project should compile without any problems. You have to manual set the linker paths for every project you create. If someone knows how to configure eclipse such that all project can be set with these paths, please edit the wiki.

Note: For reference I did this install on a 64 bit version of Ubuntu (Fiesty). Also tested on Ubuntu 9.04 jaunty with Eclipse 3.5.0 Galileo and gcc version 4.3.3 (Ubuntu 4.3.3-5ubuntu4) using allegro-4.2.2.

An alternate way for Eclipse 3.5.0

Go to: Project->Properties->C/C++ Build->Settings->GCC C++ Linker->Miscelaneous

There, click on the Add... button near the Other options list box to add a new option. In this box input the allegro config line. E.g. `allegro-config --libs` (note the backticks). This will set up all the paths, libraries and flags as above but with less effort on your part. Here is how it should look like when you are done:

Setting up allegro library in Eclipse 3.5.0

Setting up Allegro to work under Eclipse using MinGW32

The following text assumes that you have installed or will install MinGW in c:\MinGW, and allegro in c:\allegro. If this is not true, change the paths where applicable.

Eclipse and MinGW setup

You need to have Eclipse and MinGW installed and running.

  • Follow the link "Eclipse IDE for C/C++ Developers" on, download and install Eclipse.
  • In Eclipse open Help > Help Contents > C/C++ Development User Guide and follow the instructions in "Before You Begin" and "Getting Started".
    Eclipse help on MinGW setup
  • Make sure everything is all-right by compiling and running the HelloWorld program mentioned in the help.

Allegro setup

You also need allegro installed.

  • Download the latest stable version of allegro from Sourceforge. (i.e.
  • Unzip it on your hard drive, for example in the c:\allegro directory.
  • Follow instructions in the .\docs\build\mingw32.txt file. In short:
    • get the Minimal DirectX 7.0 SDK ( from Sourceforge, and unzip it into your MinGW directory, overwriting any existing files
    • make sure that your path contains the c:\MinGW\bin directory
    • set an environmental variable MINGDIR=c:\MinGW
    • go to your Allegro directory and from command line run:
> FIX.BAT mingw
> MINGW32-MAKE.EXE install
Command line building allegro
    • this may take a while depending on your hardware and will build and install the release (liballeg.a) and debuging (liballd.a) versions of the Allegro library with the appropriate .dll s.

Eclipse and Allegro setup

  • Open a C++ project in Eclipse and go to Project > Properties > C/C++ Build > Settings
  • In the Settings panel select the Tool Settings tab
  • You can manage multiple build configurations in Eclipse, the defaults are Release and Debug. Some of the options you want to set to both these configurations some options differ as mentioned below:
    • select GCC C++ Compiler > Directories in the left window and using the Add icon add c:\allegro\include for both configurations
    • select MinGW C++ Linker > Libraries in the left window
      Setting up Eclipse for Allegro
    • in the lower window (-L Library search path) using the Add icon add c:\allegro\lib\mingw32 for both configurations
    • in the upper window (-l libraries) use the Add icon to add "alleg" for the Release configuration
    • and add "alld" for the Debug configuration
    • This will add the release version library (liballeg.a) for Release builds and the debuging version library (liballd.a) for Debug builds. And yes, you have to type exactly "alleg" and "alld" ommiting the initial lib and ending .a of the filaname.
  • try compiling something using the Allegro library and, voila!


If you can't find the GCC C++ Compiler or MinGW C++ Linker in the left window of the Settings panel, return to Eclipse Help > Help Contets > C/C++ Development User Guide > Getting Started and learn more about Tool Chains and getting Eclipse to work with MinGW.

If allegro won't build, make sure you can run the mingw32-make.exe program, check that you can run gcc.exe -v. If you can't, your PATH probably doesn't contain the right path to MinGW\bin directory. If this is not the case, delete your allegro directory, get the latest stable version from Sourceforge unzip it and try again.

Setting up Allegro to work with Eclipse on Windows XP

Installing C compiler and debugger

Based on MinGW version 5.1.6 and mingw-gdb version 7.0.2.

  • Download the MinGW (Minimalist GNU for Windows) from the following URL:
  • Start MinGW.exe.
  • Window “Install or just download files” select “Download and Install”.
  • Window “Which MinGW package do you wish to install?” select “Current”.
  • Window “Choose Components” select the type of install for “Minimal”.
    • Check for “MinGW base tools”, “g++ compiler” and “MinGW Make”.
  • Window “Choose Install Location” select "C:\MinGW".

  • Add the string “C:\MinGW\bin” to the “Path” environment variables.

Installing Eclipse CDT

Based on Eclipse version 3.5.1 and CDT version 6.0.0.

  • If you want to use the GNU standard coding, select the “GNU [Built in]” under the “Window / Preferences / C/C++ /Code Style / Select a profile”.

Installing Allegro

Based on Allegro version, DirectX version 8.0 and CMake 2.8.0.

  • Download “ ” from the following URL:
  • Unzipped to the “C:\MinGW”.
  • Override all files that have the same name.

  • Download “Allegro” from the following URL:
  • Unzipped to the “C:\allegro_4.4.0.1”.
  • Make a “build” directory under the “C:\allegro_4.4.0.1”.
  • Open a command prompt and change directory to “C:\allegro_4.4.0.1\build”.
  • Launch the following commands:
    • cmake .. -G "MinGW Makefiles" or cmake .. -DCMAKE_BUILD_TYPE=Debug -G "MinGW Makefiles" for debug purpose.
    • mingw32-make
    • mingw32-make install

Configuring Eclipse

  • Open Eclipse.
  • Using the wizard, create a new C project.
  • Write a “Project name”.
  • Select “Executable - Empty Project”.
  • Press the “Next” button.
  • Press the “Advanced settings...”
  • Select the “C/C++ Build”
  • Select “Settings”
  • Select “Configuration:” = “[All configurations]
  • Select “MinGW C Linker”.
  • Select “Libraries”.
  • Add “liballeg44” in the “Librairies (-l)” section.
  • Add “C:\MinGW\lib” in the “Librairy search path (-L)”.
  • Create a new C source file.
  • Paste the code in your source file.

<highlightSyntax language="cpp">

  1. include <allegro.h>
  2. include <stdlib.h>

int main(void) {

 allegro_message("Hello World!");

} END_OF_MAIN() </highlightSyntax>

  • Build the project.
  • Get a copy of the C:\allegro_4.4.0.1\build\lib\alleg44.dll file and put it under the Debug directory.
  • Run it.

Run Test Program

Right click on your project, select New and click on Source File. Enter a name like main.c, click Finish. Copy, paste the code below into your source file. Build the source by clicking on the hammer icon. If Allegro is configured right you should get no build errors. Click on the green circle with a white arrow in it to run the program.

Out put of example code

<highlightSyntax language="cpp">

  1. include <allegro.h>

int main(){

       set_window_title("Hello World");
       set_gfx_mode( GFX_AUTODETECT_WINDOWED, 320, 200, 0, 0);
       clear_to_color(screen, makecol(255, 255, 255));
       textout_centre_ex(screen, font, "Hello, world!", SCREEN_W/2, SCREEN_H/2, makecol(0,0,0), -1);
       return 0;

} END_OF_MAIN(); </highlightSyntax>