%prevogre%

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.

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

<HR>
Creative Commons Copyright -- Some rights reserved.


THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.

BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS.

1. Definitions

  • "Collective Work" means a work, such as a periodical issue, anthology or encyclopedia, in which the Work in its entirety in unmodified form, along with a number of other contributions, constituting separate and independent works in themselves, are assembled into a collective whole. A work that constitutes a Collective Work will not be considered a Derivative Work (as defined below) for the purposes of this License.
  • "Derivative Work" means a work based upon the Work or upon the Work and other pre-existing works, such as a translation, musical arrangement, dramatization, fictionalization, motion picture version, sound recording, art reproduction, abridgment, condensation, or any other form in which the Work may be recast, transformed, or adapted, except that a work that constitutes a Collective Work will not be considered a Derivative Work for the purpose of this License. For the avoidance of doubt, where the Work is a musical composition or sound recording, the synchronization of the Work in timed-relation with a moving image ("synching") will be considered a Derivative Work for the purpose of this License.
  • "Licensor" means the individual or entity that offers the Work under the terms of this License.
  • "Original Author" means the individual or entity who created the Work.
  • "Work" means the copyrightable work of authorship offered under the terms of this License.
  • "You" means an individual or entity exercising rights under this License who has not previously violated the terms of this License with respect to the Work, or who has received express permission from the Licensor to exercise rights under this License despite a previous violation.
  • "License Elements" means the following high-level license attributes as selected by Licensor and indicated in the title of this License: Attribution, ShareAlike.

2. Fair Use Rights

Nothing in this license is intended to reduce, limit, or restrict any rights arising from fair use, first sale or other limitations on the exclusive rights of the copyright owner under copyright law or other applicable laws.

3. License Grant

Subject to the terms and conditions of this License, Licensor hereby grants You a worldwide, royalty-free, non-exclusive, perpetual (for the duration of the applicable copyright) license to exercise the rights in the Work as stated below:

  • to reproduce the Work, to incorporate the Work into one or more Collective Works, and to reproduce the Work as incorporated in the Collective Works;
  • to create and reproduce Derivative Works;
  • to distribute copies or phonorecords of, display publicly, perform publicly, and perform publicly by means of a digital audio transmission the Work including as incorporated in Collective Works;
  • to distribute copies or phonorecords of, display publicly, perform publicly, and perform publicly by means of a digital audio transmission Derivative Works.
  • For the avoidance of doubt, where the work is a musical composition:
    • Performance Royalties Under Blanket Licenses. Licensor waives the exclusive right to collect, whether individually or via a performance rights society (e.g. ASCAP, BMI, SESAC), royalties for the public performance or public digital performance (e.g. webcast) of the Work.
    • Mechanical Rights and Statutory Royalties. Licensor waives the exclusive right to collect, whether individually or via a music rights society or designated agent (e.g. Harry Fox Agency), royalties for any phonorecord You create from the Work ("cover version") and distribute, subject to the compulsory license created by 17 USC Section 115 of the US Copyright Act (or the equivalent in other jurisdictions).
    • Webcasting Rights and Statutory Royalties. For the avoidance of doubt, where the Work is a sound recording, Licensor waives the exclusive right to collect, whether individually or via a performance-rights society (e.g. SoundExchange), royalties for the public digital performance (e.g. webcast) of the Work, subject to the compulsory license created by 17 USC Section 114 of the US Copyright Act (or the equivalent in other jurisdictions).


The above rights may be exercised in all media and formats whether now known or hereafter devised. The above rights include the right to make such modifications as are technically necessary to exercise the rights in other media and formats. All rights not expressly granted by Licensor are hereby reserved.

4. Restrictions

The license granted in Section 3 above is expressly made subject to and limited by the following restrictions:

  • You may distribute, publicly display, publicly perform, or publicly digitally perform the Work only under the terms of this License, and You must include a copy of, or the Uniform Resource Identifier for, this License with every copy or phonorecord of the Work You distribute, publicly display, publicly perform, or publicly digitally perform. You may not offer or impose any terms on the Work that alter or restrict the terms of this License or the recipients' exercise of the rights granted hereunder. You may not sublicense the Work. You must keep intact all notices that refer to this License and to the disclaimer of warranties. You may not distribute, publicly display, publicly perform, or publicly digitally perform the Work with any technological measures that control access or use of the Work in a manner inconsistent with the terms of this License Agreement. The above applies to the Work as incorporated in a Collective Work, but this does not require the Collective Work apart from the Work itself to be made subject to the terms of this License. If You create a Collective Work, upon notice from any Licensor You must, to the extent practicable, remove from the Collective Work any credit as required by clause 4(c), as requested. If You create a Derivative Work, upon notice from any Licensor You must, to the extent practicable, remove from the Derivative Work any credit as required by clause 4(c), as requested.
  • You may distribute, publicly display, publicly perform, or publicly digitally perform a Derivative Work only under the terms of this License, a later version of this License with the same License Elements as this License, or a Creative Commons iCommons license that contains the same License Elements as this License (e.g. Attribution-ShareAlike 2.5 Japan). You must include a copy of, or the Uniform Resource Identifier for, this License or other license specified in the previous sentence with every copy or phonorecord of each Derivative Work You distribute, publicly display, publicly perform, or publicly digitally perform. You may not offer or impose any terms on the Derivative Works that alter or restrict the terms of this License or the recipients' exercise of the rights granted hereunder, and You must keep intact all notices that refer to this License and to the disclaimer of warranties. You may not distribute, publicly display, publicly perform, or publicly digitally perform the Derivative Work with any technological measures that control access or use of the Work in a manner inconsistent with the terms of this License Agreement. The above applies to the Derivative Work as incorporated in a Collective Work, but this does not require the Collective Work apart from the Derivative Work itself to be made subject to the terms of this License.
  • If you distribute, publicly display, publicly perform, or publicly digitally perform the Work or any Derivative Works or Collective Works, You must keep intact all copyright notices for the Work and provide, reasonable to the medium or means You are utilizing: (i) the name of the Original Author (or pseudonym, if applicable) if supplied, and/or (ii) if the Original Author and/or Licensor designate another party or parties (e.g. a sponsor institute, publishing entity, journal) for attribution in Licensor's copyright notice, terms of service or by other reasonable means, the name of such party or parties; the title of the Work if supplied; to the extent reasonably practicable, the Uniform Resource Identifier, if any, that Licensor specifies to be associated with the Work, unless such URI does not refer to the copyright notice or licensing information for the Work; and in the case of a Derivative Work, a credit identifying the use of the Work in the Derivative Work (e.g., "French translation of the Work by Original Author," or "Screenplay based on original Work by Original Author"). Such credit may be implemented in any reasonable manner; provided, however, that in the case of a Derivative Work or Collective Work, at a minimum such credit will appear where any other comparable authorship credit appears and in a manner at least as prominent as such other comparable authorship credit.

5. Representations, Warranties and Disclaimer

UNLESS OTHERWISE AGREED TO BY THE PARTIES IN WRITING, LICENSOR OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE MATERIALS, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS, WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU.

6. Limitation on Liability.

EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

7. Termination

  • This License and the rights granted hereunder will terminate automatically upon any breach by You of the terms of this License. Individuals or entities who have received Derivative Works or Collective Works from You under this License, however, will not have their licenses terminated provided such individuals or entities remain in full compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will survive any termination of this License.
  • Subject to the above terms and conditions, the license granted here is perpetual (for the duration of the applicable copyright in the Work). Notwithstanding the above, Licensor reserves the right to release the Work under different license terms or to stop distributing the Work at any time; provided, however that any such election will not serve to withdraw this License (or any other license that has been, or is required to be, granted under the terms of this License), and this License will continue in full force and effect unless terminated as stated above.

8. Miscellaneous

  • Each time You distribute or publicly digitally perform the Work or a Collective Work, the Licensor offers to the recipient a license to the Work on the same terms and conditions as the license granted to You under this License.
  • Each time You distribute or publicly digitally perform a Derivative Work, Licensor offers to the recipient a license to the original Work on the same terms and conditions as the license granted to You under this License.
  • If any provision of this License is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this License, and without further action by the parties to this agreement, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
  • No term or provision of this License shall be deemed waived and no breach consented to unless such waiver or consent shall be in writing and signed by the party to be charged with such waiver or consent.
  • This License constitutes the entire agreement between the parties with respect to the Work licensed here. There are no understandings, agreements or representations with respect to the Work not specified here. Licensor shall not be bound by any additional provisions that may appear in any communication from You. This License may not be modified without the mutual written agreement of the Licensor and You.