Skip to main content
Eclipse MingW         How to setup the Eclipse environment for use with MinGW (Toolbox) and Ogre

Tip_icon.png This information is regarding previous versions of Ogre. (Before the switch to a CMake based build system)

Info See Building Ogre for current version.

Ogre3D SDK support in Eclipse

Info Note: this page is similar to (and based on) Eclipse MingW STLPort, but uses a modified version of MinGW with Ogre1.4, instead of STLport with Ogre1.2. Currently these are simple steps that worked once for one person. There is no guarantee that this information is correct or accurate. Please change the page to make it more accurate, or discuss your experiences on the talk page.


The Idea

Our goal is to create Ogre3D applications in Eclipse, a programming environment written in java. We'll need the following components.

Eclipse
:
A C/C++ extension to Eclipse, CDT
To program C++ in Eclipse, we install the CDT extension.:
A compiler, GCC (MinGW)
CDT works with GCC, the gnu compiler collection, originally written for unix platforms (like linux or FreeBSD). To run it on windows, we need to create enough of a unix environment on windows to allow gcc to run. We have two options. One option is Cygwin, which simply translates all unix system calls to windows system calls, allowing all unix programs to run on windows with a minimum of effort. The second option, the one we'll use, is MinGW. MinGW is a collection of linux development tools (like compilers and header files) that together comprises a port of gcc to windows. We'll use a specially compiled version of MinGW that plays nice with Ogre.:
MSYS
Make, the tool that is traditionally used to configure complex gcc builds requires certain unix system commands. MSYS creates these under windows. In a nutshell, you'll be ale to use rm as well as del and ls as well as dir.:
The Ogre SDK, the Code::Blocks version
To create ogre programs, we need the ogre SDK. There are several precompiled SDK's available for different development platforms. There is no SDK specifically for Eclipse, but there is one for Code::Blocks (another programming environment) and MinGW, which will work just as well with Eclipse.:

Install Eclipse

The Core

The basic eclipse system will give you a Java development environment that can be extended for other languages. It has no installer that puts it in C:\program files\ or anything, just extract it to a directory and run Eclipse.exe.

You can download the Eclipse IDE for C/C++ Developers, with the C/C++ Development Tools Plugin already included in the package, and without any other unnecessary things.

  • Download Eclipse
  • Extract It
  • Run Eclipse.exe (The workspace is the default directory for your code.)

C/C++ Development Tools Plugin

If you already have Eclipse installed or if you prefer to install CDT separately, this is how you can install the C/C++ Development Tools (CDT) Plugin

  • Click Help > Software Updates > Find and Install
  • Select the "Search for new features to install" option and click Next
  • Check "Europa Discovery Site" and click Finish ("Callisto Discovery Site" for Eclipse<3.3)
  • Expand "Europa Discovery Site" and Check "C/C++ Development Tools"
  • Click through the Dialogs to Install and Click Yes when asked whether to reset the workspace

Install MinGW

MinGW is a windows port of gcc. It lives entirely in one directory. We'll use c:\mingw. You can put this on another drive, but it has to be x:\mingw, for the remainder of this document we will assume that c: is used. In this directory there are several subdirectories like bin and libs. MinGW consists of several packages (distributed in the form of tar.gz archives) that each have files in one or more of these directories. To install a new package, simply extract it to x:\mingw, and the files will be put in the right directories.

  • Instead of installing the required packages separately, we will install the MinGW toolbox, which contains all packages, and is compiled specially for Ogre (the regular MinGW will not work). Download this file and run it.
  • To allow the MinGW programs from c:\mingw\bin to be run from anywhere, we need to add this directory to the windows PATH variable.
    • Right-Click My Computer > Properties > Advanced > Environmental Variables>
    • Click the Path variable, (under System Variables or User Variables, depending on whether you want it set for all user, or just you respectively). Click Edit. Add ";c:\mingw\bin" (without the quotes) to the variable value. The semi-colon is used to separate directories.

MSYS installation

We need to install MSYS to have access to linux-style shell commands.

  • Download MSYS-1.0.10.exe
  • Install it somehwere. We'll use c:\msys
  • the post installation script will ask you where the mingw installation is located. This is c:\mingw
  • To allow the MSYS programs from c:\msys\bin to be run from anywhere, we need to add this directory to the windows PATH variable too.
    • Right-Click My Computer > Properties > Advanced > Environmental Variables>
    • Click the Path variable. Click Edit. Add ";c:\msys\bin" (without the quotes) to the variable value. Note, if you chose some other directory for the installation, and it has spaces in the path, enclose the directory in quotes.

Check if it works

To check if everything works, fire up a command prompt (start a fresh one after you set the path variables) whit Start Menu > Run... > Type 'cmd'. Type the following commands.

Copy to clipboard
gcc -v rm --version


For both files, you should get some version information. If you get 'is not recognized as an internal or external command, operable program or batch file', windows can't find the programs. Check if the Path variable is set correctly.

Install OgreSDK

To create Ogre3D software we must install the Ogre SDK.

OgreSDK Configuration

In eclipse, go to Window > Preferences > C/C++- > Environment

(This was Window > Preferences > C/C++- > PathEntry Variables in CDT<4.0 and Eclipse<3.3)

Click the 'New...' button

Put this info:

  • Name: OgreSDK
  • Location: C:\OgreSDK


You may also want to stop Eclipse from auto-building projects: Project > uncheck 'Build Automatically'

Creating a New Project

Now, it's time to set up a new project in Eclipse, and see if everything works.

  • File > New > Project
  • C++ > C++ Project (C++ > Managed make project in older versions of Eclipse+CDT)
  • Set a name for your project. We'll use OgreTest
  • Select "Executable" in the Project Types tree to the left
  • Select "MinGW GCC" in the Toolchain list to the right
  • Press Next. You will see two build configurations, leave them both checked.


There are two different sets of options; the first, 'Debug', is used during programming. It doesn't any optimization, and allows debugging of the compiled file in several ways. The second, 'Release', is used to create the finished executable, that you will distribute to other people. It tells the compiler to optimize, and doesn't allow any debugging is anything goes wrong.

Build Configuration

The gcc C++ compiler and C++ linker have an ocean of possible configuration option. We'll need to set ours up quite carefully, and differently for each one of the Build Configurations (Debug and Release).

  • Right-Click your Project in the Left Pane and Click Properties
  • Select C/C++ Build > Settings on the Left.
  • Set the Configuration Pull-Down to Release or Debug and in the Tool Settings tab, enter the options from the table below in the appropiate section of the small left tree:

GCC C++ Compiler

Debug Release
Add the following to the Defined Symbols (-D)
WIN32
_WINDOWS
_DEBUG
Add the following to the Defined Symbols (-D)
WIN32
_WINDOWS
* NDEBUG
Add the following to the Include Paths (-I)
"${OGRE_HOME}\include"
Note: Add this with quotes
Add the following to the Defined Symbols (-I)
"${OGRE_HOME}\include"
Note: Add this with quotes
Miscellaneous
Put the following in the 'other flags text box:
-c -fmessage-length=0 -mthreads -fexceptions -fident
Put the following in the 'other flags text box:
-c -fmessage-length=0 -mthreads -fexceptions -fident

GCC C++ Linker

DebugRelease
Add the following to the libraries (-l)
OgreMain_d
OIS_d
Add the following to the libraries (-l)
OgreMain
OIS
Add the following to the library search path (-L)
"${OGRE_HOME}\bin\debug"

Note: Add this with quotes
Add the following to the library search path (-L)
"${OGRE_HOME}\bin\release"

Note: Add this with quotes
Miscellaneous
Add the following to the Other Options (-Xlinker[option]
--enable-auto-image-base
--add-stdcall-alias
Add the following to the Other Options (-Xlinker[option]
--enable-auto-image-base
--add-stdcall-alias

Notes

  • Eclipse will build with the Configuration you leave selected. You can also change this under Project > Active Build Configuration

  • OGRE_HOME is a pre-defined environment variable setup by the SDK installer. OGRE_HOME points to the directory where the SDK is installed. You can use ${OGRE_HOME} within your build options when setting up paths to specific directories with the SDK that you will need to access.

Basic Tutorial 1

We can test our project with Basic Tutorial 1

  • Make a New C++ Source File, name it something like Tutorial1.cpp
  • Copy the Code from Basic Tutorial 1 into the file
  • We need to tell the compiler where ExampleApplication.h is.
    • Under the Project Properties
    • C/C++ Build > Settings > Tool settings > GCC C++ Compiler > Directories > Include Paths, Add:
    • "${OGRE_HOME}\samples\include"
  • Click Project > Build All


The project will compile Tutorial1.cpp into OgreTest.exe, and put it in your workspace under OgreTest/Debug, or OgreTest/Release, depending on your build configuration.

Required Files

If you try running your program it will complain about missing DLLs.

  • If your .exe is in the Release directory, copy all files from c:\OgreSDK\bin\Release to it. For the Debug directory, copy all files from c:\OgreSDK\bin\Debug.


If you try running now, Ogre will give an error about not finding the media directory.

  • Copy the c:\OgreSDK\media Folder to your Workspace directory, (2 directories below your .exe)

Note: The resources.cfg file tells Ogre where to find these media files. If you wish to put this folder somewhere else you need to edit this file.

Note: Cleaning your project will remove all these files, I'm not sure how to change this behavior

DirectX

If you don't have the DirectX Runtime installed you will get an error about a missing d3dx9_30.dll or d3dx9d_30.dll (for Debug builds). To get this dll, you need to install DirectX, or the DirectX SDK for Debug builds. Note that the dll's needed for Ogre 140 end in 30. For other versions of Ogre, other versions of this dll are needed.

End-Users just need the Latest DirectX Runtime (Supplies the d3dx9_##.dll file needed for your Release build):


To Debug you need the DirectX SDK (Supplies the d3dx9d_##.dll file needed for your Debug build):

Note: The SDKs come with only one d3dx9d_##.dll file. April, June, and August are 30. February is 29.

Font spacing issues

If you have a font spacing issue with your programs after making a program with eclipse, make sure you upgrade to the latest version of mingw. The full toolchain is not needed for ogre 1.6+ so installing the latest mingw should fix this problem.


Alias: Eclipse_MingW