Setting up an OGRE on Windows with MinGW.

I built the OGRE SDK for Windows 7 with MinGW/MSYS compiler. My build will not work with other compilers. I have not tried it on other versions of Windows.


Get the software

MinGW/MSYS

  1. Download the MinGW installer from http://www.mingw.org/. The installer download button is in the top right corner of the screen. Install mingw in C:\MinGW. Make sure you get the C++ packages.
  2. Add C:\MinGW\bin;C:\MinGW\msys\1.0\bin to your path environment variables. You can find instructions for different flavors of Windows at this Java website.

OGRE

  1. Create a directory called C:\GameDev.
  2. Download winFiles/ogreWinMinGW.zip.
  3. Unzip the file in C:\GameDev. You should have the folder C:\GameDev\OgreSDK
  4. Add C:\GameDev\OgreSDK\bin to your PATH as above.

Eclipse/CDT

If you already have eclipse, you can download the CDT. Use the instructions for the p2 software repository.

If you do not have eclipse, do the following:

  1. Download the Java Development Kit if you don't already have it. The Java Runtime will probably suffice, if you don't plan on doing any Java Development.
  2. Download eclipse from eclipse.org. There is a download for C++ developers that comes with CDT.
  3. The file that it downloads will be a zip file. I unzipped mine and put it in C:\Program Files, but it doesn't matter. You will have to create your own shortcuts from the the desktop, or menus to use it.

Creating a project

  1. Create a new empty C++ project in Eclipse. Use the MinGW Tool Chain. Give it a name and hit the "Next" button.

  2. Click the "Advanced Settings..."

  3. Click the "C/C++ Build" drop-down on the left.

  4. Click Environment

  5. At the top of the "Tool Settings" tab, select "[All Configurations]" in "Configuration:". You may need to scroll up, to see it.

  6. Add two environment variables with the "Add..." button.

    NAME=OGRE_HOME      VALUE=C:\GameDev\OgreSDK
    

  7. Click "Settings" under "C/C++ Build" on the left side of the window.

  8. In the "Tool Settings" tab, click "Includes" under "GCC C++ Compiler"

  9. Click the Add button icon (a document with a green plus sign on the right).

  10. You will need to add the directories where the include files are for OGRE, CEGUI, OIS and boost. You can type exactly what appears below. Eclipse will use the variable ${OGRE_HOME} here.

    ${OGRE_HOME}\include\OGRE
    ${OGRE_HOME}\include\OGRE\Overlay
    ${OGRE_HOME}\include\OIS
    

  11. Click "Libraries" under "GCC C++ Linker". In the section "Libraries (-l)" add the following names:

    OgreMain
    OgreOverlay
    OIS
    OgreRTShaderSystem
    
  12. Add the library paths in the "Library search path (-L)" area.

    ${OGRE_HOME}\bin
    
  13. Click "Ok".

  14. Click "Finish".

  15. Create a src directory inside your project directory.

  16. Copy resources.cfg plugins.cfg files into the top level of your project.

  17. In eclipse, right click on your new project and select "Refresh".

  18. You might need to turn off the Direct3D renderer if the version on your system is not the EXACT version used to build Ogre. Put a # in front of the line "Plugin=RenderSystem_Direct3D9". Once you get it building with OpenGL, try uncommenting the line and see if it works. You can also build Ogre's plugins yourself so it matched your system, but I'm not going in to that detail here.

  19. Download the four .cpp and .h files in http://cs.gettysburg.edu/~cpresser/cs391/software/winFiles to your src directory.

  20. In eclipse, right click on your new project and select "Refresh". You are now ready to edit your OGRE project. Make sure you build it (Hammer Icon) once before attempting to run it.

  21. The next time you want to set up a project, right click on this project and Copy it. Paste it, give the new one a different name, delete the files in src and run "Clean..." from the "Project" menu for the new project. You won't have to enter in all of the new settings again.


Problems

The program does not compile

Make sure all of your environment variables, paths, libraries and settings were typed correctly. Look at the output and try to figure out what is missing.

The program compiles, but terminates immediately when executed

I've notice this with 64 bit systems (64 bit Java, 64 bit eclipse, Windows 7). Eclipse seems to ignore the PATH variable, so we have to make sure the proper path is set for execution.
  1. Open your project properties (right click on the project and select "Properties..."

  2. In the left side of the window, select "Run/Debug Setting"

  3. Click the executable name and click the "Edit..." button.

  4. In the new window that pops up, click the "Environment" tab.

  5. Click the "New..." button.

  6. In the new environment variable dialog add:

    Name=PATH
    VALUE=C:\MinGW\bin;C:\GameDev\OgreSDK\bin
    
    Replace the paths with the actual values for your installation. You cannot use the OGRE_HOME variable here.

  7. Now try to run the program.