Setting up Eclipse/CDT to use Irrlicht under linux:

Introduction:

Because I had some trouble getting the Irrlicht engine to work under Linux, I decided to write this mini tutorial in case others have the same problems. I will describe the steps it took to get the first official Irrlicht tutorial to run. I will not describe how to compile the Irrlicht engine on Linux, because I use the prebuilt libraries. Since I'm using Gentoo Linux the described paths and libraries could differ for other distros. I assume you have Eclipse and CDT allready installed (My versions are: Eclipse: 3.0.1 and CDT: 2.0.2). I use "Menu"->"Submenu" as notation for Menus or tabs to select or when I quote Eclipse directly. Please excuse any mistakes and send corrections to andreas.sensen@sensobots.de. The tutorial is devided into the following steps:
  1. Installing the Irrlicht engine
  2. Starting a new C++ project
  3. Compiler and linker configuration
  4. Compiling and running the programm

Installing the Irrlicht engine:

First I downloaded the latest Irrlicht SDK (this howto describes version 0.7). I unpacked it into the folder /opt/noebuild/irrlicht. The Irrlicht header files are in /opt/noebuild/irrlicht/include, the Linux libraries in /opt/noebuild/irrlicht/lib/Linux.

Starting a new C++ project:

After starting eclipse-3 select "File"->"New"->"Project". In the new window select "C++"->"Managed Make C++ Project". For the project name I used "test" and "Finished".

new project
Select test in the Navigator tab, press the right mouse button and select "New"->"File" to create a "main.cpp". Now the main.cpp should have been opened and you can enter the source code from Tutorial 1 to the new project (you can omit the line #pragma comment(lib, "Irrlicht.lib").

Compiler and linker configuration:

Now for the part that took me some time. :-)
First we need to tell g++ where to find the Irrlicht headers. Select "Project"->"Properties" and jump to the "C/C++ Build" section. Select "Directories" and add /opt/noebuild/irrlicht/include.

include directories
Next tell the linker where to find the needed libraries: select "Libraries" and add /opt/noebuild/irrlicht/lib/Linux and /usr/X11R6/lib to "Library search path (-L)" (/usr/X11R6/lib should usually allready be in the library search path, but I had to add it manually, maybe it's gentoo specific?!?). Then add the following names to the "Libraries (-l)" section (all case sensitive!): "Irrlicht", "jpeg" and "z" (the Irrlicht libraries), "GL" and "GLU" (OpenGL libraries), "X11" and "Xxf86vm" (some X libraries). Again you might omit the non-Irrlicht-libraries, maybe it's just my system that needs them explicitly named in Eclipse.

libraries directory

Compiling and running the programm:

Everything is ready for compilation now. "Project"->"Build All" will hopefully compile main.cpp without errors. If you don't like the many warnings you get in the console, deselect "All warnings (-Wall)" in "Project"->"Properties" (section "C/C++ Build"->"Warnings"). To run your program from within Eclipse, select "Run"->"Run". In the upcoming window you have to select the "C/C++ Application:" to run. Use the Browse button to select the "test" binary from the "Debug" directory (this should be the default). Then click "Run" and enjoy your 3D application.

I hope the tutorial was helpfull. :-)
© Andreas Sensen 2005, All Rights Reserved