Guide : integrate Ogre with Eclipse

Problems building or running the engine, queries about how to use features etc.
Post Reply

Useful ?

Needs work
No votes
Total votes: 14

User avatar
Posts: 657
Joined: Mon Feb 28, 2005 1:53 pm
Location: Australia - Canberra (ex - Switzerland - Geneva)

Guide : integrate Ogre with Eclipse

Post by steven »


I would like to propose a "simple" guide to integrate Ogre and Eclipse.
It is very basic but at least you can compile, run and debug a simple Ogre project with Eclipse.

I will edit this guide if someone has suggestions.

UPDATE JULY 05 : I created a new guide to integrate Ogre with MinGW + Msys without cygwin. See :

Guide to integrate Ogre to Eclipse

Professionally I use Windows XP so I will first describe the procedure for a Windows environment. I hope to install the Eclipse for Ogre on my Debian home-machine but … later.

Rational for the choice of Eclipse :

- Using the same environment under Windows and Linux
- Building with free tools
- Creating Ogre applications with C++ and Java (Ogre4J)

Even if Netbeans is better for Java, it completely lacks support for C++. Perhaps in the future.
Even if Code::Blocks is better for C++, it lacks support for Java.

AFAIK, Eclipse is the only tool responding to these criterions.

A - Linux


B - Window platform

1 - Download and install Eclipse Platform SDK

- Get the last versions of the Eclipse SDK from (Version 3.0.1 : ou du CVS eclipse (Version 3.1M5 :
- Unzip the content of the zip in the intended directory (for example: C:\Program Files\Eclipse).
- To simplify create a shortcut eclipse.exe on the desktop :-)
- Run the SDK. It will ask a directory where you want to put the project (for example: C:\bla\bla\Eclipse).

At this stage you have a fully functional Java development environment. But nothing for C/C++ for this you first need to add a C/C++ « perspective » in the eclipse platform.

2 - Download and install Eclipse CDT (C/C++ Development Tools)

TODO : The 3.0 release will be available in may 2005.

- Get the last version of Eclipse CDT at (Version 2.1 :
- Unzip the content of the zip in the Eclipse SDK directory. This means:
1) Put the content of the zip directory eclipse\features (the directory ogr.eclipse.cdt_2.1.0) in the appropriate directory (for example: C:\Program Files\eclipse\features).
2) Put the content of the zip directory eclipse\plugins (the directories org.eclipse.cdt.*) in the appropriate directory (for example : C:\Program Files\eclipse\plugins).
- Exit and run again the eclipse platform.
- Test the presence of the newly installed eclipse « perspective » by selecting it using the menu Window/Open Perspective/Other and selecting « C/C++ ».

At this stage you only have an environment capable of browsing/managing C/C++ files and projects and able to manage an debug environment. Nothing more ! There is NO compiler/debugger provided with Eclipse. You need to add you own C/C++ tools.

3 - Choose the C/C++ Development Tools

The page describes how to integrate several freely available development tools. There is a description how to integrate the free MS Visual C++ Toolkit. However, I became suspicious with the notion « free » with Microsoft, especially if you read the Toolkit EULA.

As I understand it, is possible to compile OGRE with GCC. So I will stick with it. :-)

Several choices are possible :

- Cygwin
- Mingw + msys : msys is a limited mini Cygwin where all necessary tools (including autoconf, automake) are available.
- Cygwin (for Ogre compilation) + Mingw (for your project): however be warned that the cygwin gcc has usually an older version of the latest stable Mingw’s gcc.

The Ogre thread comparing Cygwin and Mingw explains that both can be used to compile ogre with pure native win32 code: by passing ‘-mno-cygwin’ to the gcc supplied by Cygwin, this compiler generates Mingw code!. See : ... sus+cygwin

It is not obvious which one is more easily incorporated in Eclipse, however there seems to be more Ogre people (aka support) for the first solution, so the Cygwin will be the first try.

TODO : Try to compile Ogre with Eclipse and MinGW only … without any auto tools.

4 - Using Cygwin

For this solution, I strongly advice that you follow EXACTLY all the steps in the chapter about Cygwin in the wiki AbsoluteNewbiesGuide : ... uidetoOGRE

However, a few commentaries about this guide :

4.1 - When you run the « Cygwin_setup.exe » :

- You must choose an install directory (which will be named the root directory in cygwin), for example C:\Work\Cygwin. THIS DIRECTORY MUST NOT HAVE SPACE IN IT! This means you should not install it in « /Program Files/ » !
- Choose for the « Default Text File Type » : DOS. I didn’t try Unix so I am not sure if this could create a problem with some Linux version of Ogre configuration files (.cfg files).
- Two options : full options (the simplest :-) ) or choosing only the necessary packages : TODO include a list of essential packages?

4.2 - If you don’t have libtool version 1.5.12 or newer.

- You must install the cygwin version of libtool and then install a new libtool version ! Because Cygwin install a script (/usr/bin/libtool) that is NOT installed durintg the « make install » of the newer version of libtool ! Only installing the new gnu libtool will not be enough.
- Or you can follow the advice of Snide in his message : . (I didn’t try it but it should probably work).

4.3 - To be able to use the C++ tools (g++, make, etc) outside a Cygwin console, you need to change the Windows environment variable PATH by adding the complete name of the Cygwin bin folder. For examples C:\Work\Cygwin\bin .

4.4 - Test Eclipse with the Cygwin tools after the fifth step in the AbsoluteNewbies guide.

If Eclipse was open during the installation of Cygwin you must launch it again so that Eclipse takes the modified environment variable into account.

Create a simple « Hello world » program to test it :

Code: Select all

#include <stdio.h>

int main(void)
	printf("Hello, world!\n");
	return 0;
Everything should run correctly but …good luck if you are not familiar with the Eclipse platform….

4.5 - Get the Ogre sources using CVS

We could get a precompiled version of Ogre but it is evolving (and correcting bugs) so quickly that building Ogre from the CVS version seems a better choice. Especially if you find an Ogre bug and want to submit a patch. The ogre site gives a detailed explanation of the use of CVS for Ogre: ... &Itemid=87.

For newbies, choosing the maintenance version (Azathoth) is perhaps the easiest choice.

TODO Careful ! Note that until the problem mentioned in the following topic persist : ... guiogre+pc , it is perhaps best to get the version tag « v1-0 » ( - not . ) and not with the tag Azathoth. Verify that you have this .pc file.

- Run cygwin and go to the directory where you want to put the ogre source. (On an unix platform the usual directory would be /usr/dev/ogre ).
- By typing the next command the cvs will download in a new folder « ogrenew » the sources files : cvs -z3 co -P -r <branch_name> ogrenew
- To update to the latest version. Type from inside the ogrenew folder : cvs -z3 up -Pd

4.6 - CEGUI is not present in the CVS.

It is a third party library hence the CEGUI sample will not be build.

TODO : Try to compile it and find info about a the forum message mentioning a difficulty to compile CEGUI with Mingw.

(4.7 - I was obliged to launch « make install » twice !? The first pass didn’t install all the DLL correctly and the samples didn’t run. Why ?)

4.8 - cfg files

Some of the downloaded CVS .cfg files are specific to Linux (especially Samples/bin/plugin.cfg)! Linux version contains references to .so files (shared object).

This is a bit annoying because you must first understand how Ogre works before you can even try the samples (for example, to verify if everything was correctly compiled).

You need to edit it for the Windows platform and edit the path to the folder where you put all the .dll created. Secondly you must verify that you .cfg have DOS line feeds (and not Unix or Mac endlines).

A simple and fast fix is to copy all the generated .dll in /Samples/Common/bin and run the examples directly from this directory.

TODO : list all the .dll needed.

The Cg.dll is not an Ogre one, you need to download it from another site. For example, Nvidia.

Secondly, I don’t have DirectX 7 and 8 on my platform so I need to comment out both lines. The FileSystem plugin doesn’t exist anymore and the NatureSceneManager was moved to the ogre add-ons and is no more in the CVS … so why are those references still in the CVS ?

Code: Select all

# Defines plugins to load

# Define plugin folder

# Define D3D rendering implementation plugin
Finally, all samples work.

Except (perhaps) the BSP.exe because, the CVS quake3setting.cfg must be adapted to your environment :

- Download the compiled samples from the ogre site, use its .cfg and its .pk3 (which containing the quake level)
- Put the .cfs with the others .cfg files.
- Put the .pk3 in the Samples\Media\packs folder.
- Now, the BSP demo should run.

5 - Setting Eclipse for Ogre

Finally! We begin the interesting part… integrating Ogre with Eclipse.

5.1 - Launch Eclipse and create a « Managed C++ project ».

5.2 - Create « Your First Program »

Use the code mentioned in the AbsoluteNewbies and called it for example OgreHello.cpp. Trying to compile this should produce several warnings and errors.

5.3 - Linking with Dll, .la, ..a and .h files.

You must link your program with the dependent files (.dll, .h, .la, .a and .exe). You can look at ... pplication explaining recommended settings and listing the dependent files for an Ogre project.

You have basically two choices :

1) Either you let the necessary .dll, .h,, .a and .exe in their place in the \usr\dev\ogrenew folder and you link and set the environment variable to those folders
2) Or you copy them in a separate folder. Which I did so I can make archives of my libraries. Personally, I created a folder « ogre-1.0.0 » in which I copied the files :
- C:\bla\bla\Cygwin\usr\local\bin to ogre-1.0.0\bin
- C:\bla\bla\Cygwin\usr\local\include to ogre-1.0.0\include
- C:\bla\bla\Cygwin\usr\local\lib to ogre-1.0.0\lib
- All .h files from C:\bla\bla\Cygwin\usr\dev\ogre\ogrenew\Samples\Common\include\ to ogre-1.0.0\include.

5.4 - Properties for OgreHello

We need to set several properties of you project.

- Right-click on the project folder in the navigator tab. And under the C/C++ Build page select the Tool Settings.
- In GCC C++ Compiler -> Directories : add the directories were you put the ogre .h files. For examples, C:\bla\bla\ogre-1.0.0\include and C:\bla\bla\ogre-1.0.0\include\OGRE.
- In GCC C++ Compiler -> Miscellaneous : add the flag « -mno-cygwin » to compile mingw compatible code.
- In GCC C++ Linker -> Libraries : add the library « OgreMain »
- In GCC C++ Linker -> Library Search path : add the path where you put you .dll. For example C:\bla\bla\ogre-1.0.0\lib.
- In GCC C++ Linker -> Miscellaneous : add the flag « -mno-cygwin -WI,--enable-runtime-pseudo-reloc ».
- Click OK and the project should automatically recompile (if not make use Project -> Clean…).
- You should now have an .exe under the Debug folder.

Note : If you installed Mingw, the « Tool Settings » and « Build Setting » must be different. At least you must modify the default build command to : make -k but mingw32-make.

5.5 - Add the .cfg and resources

Ogre applications use .cfg to find plugins and other resources. We need to copy the Windows specific .cfg file in the root folder of the Eclipse project. For example, « C:\bla\bla\Eclipse\OgreHello\ ».

- Copy the Ogre folder ogre new\Samples\Media containing resources needed by the ExampleApplication.h to a project directory.
- Open the resources.cfg and change the relative path so that it points to this folder.

5.6 - Run the application

- Under the menu Run, choose Run… this will open run configuration panel.
- Create a new one.
- If the .exe is not automatically selected, browse for it.
- Under the Environment tab, you must add a new variable which will set the Windows Environment variable PATH. Click new and add for the « Name » : PATH and for the « Value » put the path to you bin where libOgreMain-5.dll is. For example: ${env_var:PATH};C:\bla\bla\ogre-1.0.0\bin;C:\Work\Cygwin\usr\dev\ogre\ogrenew\Samples\Common\bin .

Tada… your first exe should execute when you run it from Eclipse. :wink:
Last edited by steven on Thu Jul 28, 2005 4:23 pm, edited 2 times in total.
OGRE Contributor
OGRE Contributor
Posts: 570
Joined: Mon Mar 01, 2004 10:35 am
Location: Hamburg, Germany

Re: Guide : integrate Ogre with Eclipse

Post by reimpell »

steven wrote:4.5 - Get the Ogre sources using CVS
One could use Eclipse's "CVS Repository Exploring" perspective, although I never managed to choose any other branch than HEAD. Also, I always lost my project properties by using "Replace With -> Latest from HEAD".

Furthermore, I haven't found a way to use the config dialog (SDL resp. console) with the debugging perspective as I wasn't able to type my choices into the console view such that they got accepted.
User avatar
Posts: 657
Joined: Mon Feb 28, 2005 1:53 pm
Location: Australia - Canberra (ex - Switzerland - Geneva)

Post by steven »

One could use Eclipse's "CVS Repository Exploring" perspective, although I never managed to choose any other branch than HEAD. Also, I always lost my project properties by using "Replace With -> Latest from HEAD".
To retrieve a different branch with the Eclipse CVS :

- Open the "Repository view"
- In the "Versions" branch, right-click on the "ogrenew"
- Select "Configure Branches and Versions...", this will open a dialog where you can "browse for tags".
- Select a file (containing tags for example "README 1.4"), on the right should appear "New tags found in the selected files", you should see a list of tags : vbo-unstable, v0-15, v1-0, Azathoth, etc. etc.
- Select the tags you want with "Add Checked Tags"
- Click "OK" and the new selected branches should appear in the folder "Branches".
Post Reply