Setting up an OGRE Eclipse project on MacOS.


Mac is a little different than the other systems. First, some of the required libraries and include files are packaged together in frameworks, which will require some different types of arguments for g++. Second, Mac Apps are actually directories called bundles that contain the executable and resources such as dynamic libraries. Dealing with the first issue in Eclipse is pretty easy. Dealing with the second requires a bit more effort.


Software Notes

  1. Get Eclipse with CDT: You can find directions at: http://max.berger.name/howto/cdt/cdt.jsp. The next two steps have some notes concerning this setup. You will need Java to run eclipse, so you may want to download that as well.

  2. Download the OGRE SDK. Extract it to some easy to remember directory e.g /Applications/GameDev/OgreSDK. This directory should contain a bin, lib, include directories among other things. For the rest of these instructions I will refer to this directory as /path/to/ogre.

  3. IMPORTANT: I've provided some files to help create the Mac App Bundle. Create a folder in your Ogre SDK folder called mac. Download the two files from http://cs.gettysburg.edu/~cpresser/cs391/mac/ and save them to this directory. You should make sure that buildApp.sh is executable.

Building CEGUI

Build CEGUI. You may be fortunate enough that your download of CEGUI was built using the same version of Ogre that you downloaded, or you may have done your research and intentionally got versions tha match. This is probably the way to go. If you didn't however you have a little bit of work to do.

If your project will not use CEGUI, you can skip this step and then skip all of the steps that involve CEGUI in the instructions to build a project.

  1. Get the CEGUI source code and decompress it in a directory like Ogre. I used /Applications/GameDev/CEGUI. Decompressing the archive produces another folder, so the full path to my CEGUI install will be /Applications/GameDev/CEGUI/CEGUI-0.7.5. For the rest of these instructions I will refer to it as /path/to/cegui.

  2. Download the Mac dependencies archive from CEGUI and decompress it in /path/to/cegui. There should now be 2 more folders: "dependencies" and "__MACOSX".

  3. In the finder open up /path/to/cegui/projects/Xcode

  4. Double click on CEGUI.xcodeproj to open it in Xcode.

  5. Once open, click on CEGUI (the first line) in Groups & Files to select it.

  6. Click the Info icon.

  7. In the Architectures section, select the most recent "Base SDK" in the list. I used "Mac OS X 10.6".

  8. Remove all of the "Valid Architectures" except "i386".

  9. Scroll down the page to the "Compiler Version" sections. Select the most recent version of GCC.

  10. Scroll down to the "User-Defined" section.

  11. Change "CEGUI_BOOST_PATH" to /path/to/ogre/boost_1_42. Make sure you have the correct version number in the path name.

  12. Change "CEGUI_OGRE_SDK_PATH" to /path/to/ogre

  13. Close the Info window.

  14. Click "Build and Run"

  15. Once this is done an application will pop up which you can quit.

  16. Click the arrow next to "Targets" in the "Groups and Files" section of the window.

  17. Right click on "CEGUIOgreRenderer" and select "Build CEGUIOgreRenderer"

  18. Go back to the Finder in /path/to/cegui and create two folders: "Frameworks" and "Plugins".

  19. Create a "Release" folder in both folders from the previous step.

  20. Copy all of the files that end in ".framework" from projects/Xcode/build/Release to Frameworks/Release.

  21. Copy all of the files that end in ".bundle" from projects/Xcode/build/Release to Plugins/Release.


Creating a project

  1. Create a new empty C++ project in Eclipse. 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=/path/to/ogre
    NAME=CEGUI_HOME     VALUE=/path/to/cegui
    
    Be sure you replace the paths with the actual path where Ogre and CEGUI reside.

  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 variabl ${OGRE_HOME} here.

    ${OGRE_HOME}/include/OGRE
    ${OGRE_HOME}/include/OIS
    ${OGRE_HOME}/boost_1_42
    ${CEGUI_HOME}/Frameworks/Release/CEGUIBase.framework/Versions/A/Headers
    

  11. Click "Miscellaneous" under GCC C++ Compiler.

  12. In the "Other flags" text box append -arch i386 after the flags that are already there. Be sure to include a space between them.

  13. Click "Libraries" under "MacOS X C++ Linker". In the section "Libraries (-l)" add the following names:

    OIS
    OgreProperty
    OgrePaging
    OgreRTShaderSystem
    OgreTerrain
    
  14. Add the library paths in the "Library search path (-L)" area.

    ${OGRE_HOME}/lib/Release
    ${OGRE_HOME}/lib
    
  15. Click "Miscellaneous" under "MacOS X C++ Linker". In the "Linker flags" text box put the following, all on one line.

    -arch i386 -F${OGRE_HOME}/lib/release -F${CEGUI_HOME}/Frameworks/Release -framework Ogre  -framework OpenGL -framework IOKit -framework Carbon -framework Cocoa -framework CEGUIBase -framework CEGUIOgreRenderer
    

  16. Now click the "Build Steps" button. In the "Command" text box under "Post-build steps" add the following:

    ${OGRE_HOME}/mac/buildApp.sh ${ProjName} -cegui

  17. In the "Description" text box, add the sentence, "Create the Mac app bundle."

  18. Click "Ok".

  19. Click "Finish".

  20. Create a src directory inside your project directory.

  21. Copy all of the .cfg files from /path/to/ogre/bin main directory.

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

  23. Double click "resources.cfg" and change all of the "../../.." to "/path/to/ogre" without quotes.

  24. Save "resources.cfg"

  25. Download the four Tutorial files in http://cs.gettysburg.edu/~cpresser/cs391/base/ to your src directory.

  26. 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.

  27. 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 outoput and try to figure out what is missing.

The program can't find resources.cfg when I use Ogre's tutorial files.

My BaseApplication.cpp file is slightly different from OgreWiki Tutorial's. I added a few lines of code (copied from the SampleBrowser's source) so it could find the configuration files within an app bundle.

Program isn't portable

You can change the buildApp.sh so that it copies the resource instead of making a symbolic link (shortcut), so you can put your app bundle on another Mac and have it run. This will also require that you put copy any media files you used into the bundle and update resources.cfg to reflect this. I haven't tried this