Eclipse

From Allegro Wiki

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


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)


Contents

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.

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, 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 Managed Make C++ project. Now, right click on your project in the C++ Projects window. Go into the C/C++ Build section and open up the GCC C++ Linker part of the tree. Click on the Libraries section. You should see two lists for the options -L and -l.

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 (omit the -L flag). 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. Only add the part after the -l (i.e. alleg).

Now that we have our libraries added, click on Miscellaneous. 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.


Note: For reference I did this install on a 64 bit version of Ubuntu (Fiesty).

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 http://www.eclipse.org/downloads/, 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. alleg422.zip)
  • 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 (dx70_mgw.zip) 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
> MINGW32-MAKE.EXE DEBUGMODE=1
> MINGW32-MAKE.EXE install
> MINGW32-MAKE.EXE install DEBUGMODE=1
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!

Troubleshooting

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.

Personal tools