Guide to Installing Ogre3D on Mac OS X (Xcode + Ogre SDK 1.7.3)

This guide serves as an introduction to getting started with Ogre3D on Mac OS X, namely setting up the development environment and building a basic application. It’ll serve as the first in several series of blog posts I intend to write on the subject. Let me say this first. I am not an expert on Ogre, 3D graphics development or theory, or Macs. I may get the jargon wrong and my instructions may not work for very system, so contacting me for help may not the best thing to do, however I’ll do what I can to assist if you do.

There is a lot of information on Ogre in general on the Internet, but not too much on configuring it on Mac or Linux. I will write a document for installing Ogre on Linux at a later date, but for now it’s OSX time. Also, you should definitely visit the Ogre Wiki after reading this tutorial for even more information.

Step 1 – Download & Install Apple Xcode IDE

To get started, you should first get the Xcode IDE if you don’t already have it. Apple makes it available as a free download after you create an account on their website (the 3.x version is free at the time of this writing). Visit the Apple Developer Website to download a copy of the Xcode 3 IDE. After you download Xcode, then install it. I’m not going into detail for this step as it’s very straightforward to install the Xcode IDE.

Step 2 – Download & Install NVIDIA Cg Toolkit

The NVIDIA CG Toolkit isn’t required but is needed for the Ogre Cg Program Manager. To install the toolkit, you’ll need to go to the NVIDIA developer website, create a login if you don’t already have one, then download the Mac OS X DMG image. To do this, visit the NVIDIA Developer Cg Toolkit Page and scroll to the bottom of the page. Click on the download link. On the Access Denied page, click on the Login link. Proceed to create an account by clicking on the Create new account tab. Go back to the download page and fetch the Mac OS X file image. Install the NVIDIA Cg Toolkit it like you would any other Mac setup package.

Step 3 – Download & Install Ogre SDK 1.7.3 & OSX Dependencies

At the time of this article the current version of Ogre3D is 1.7.3. To keep things simple we’ll be installing the prebuilt release of Ogre SDK for OS X instead of compiling from source. To get started, we have to visit the Ogre3D website and download the Ogre 1.7.3 SDK for Mac OS X. On that page there is a link to the latest Mac OS X Ogre3D release. Download the Ogre SDK to your computer (it’ll be a .DMG Apple Disk Image File). Double-click the Ogre SDK DMG to mount the disk image.Ogre3D 1.7.3 SDK for Mac OS X window

You’ll be greeted with an Ogre SDK window (as shown on the left). There is a blue folder called OgreSDK in that window, ctrl-click (aka right-click) on that folder and select the Copy “OgreSDK” menu option. Paste the folder to your hard drive (I recommend the root, that being /OgreSDK). Open a Finder window, select your hard drive under Devices, ctrl-click and Paste the OgreSDK folder.

Copy OgreSDK folder to hard driveAs you can see from the image to the right, the OgreSDK folder is quite large so the copy process may take a moment. When it’s done we move on to the next step, that being installing the Ogre dependency files. There is a zip file containing dependencies we’ll need to be able to build our own Ogre Mac OSX applications, and these dependencies are boost, FreeImage, freetype, OIS, and zzip.

The Ogre Mac OSX dependencies zip file is located on SourceForge. When you get there, follow the ogre-dependencies-mac -> 1.7 folder path. Download the file OgreDependencies_OSX_20110208.zip and extract its contents. You’ll get a folder called Dependencies. Move that folder into the /OgreSDK folder (or wherever you put yours).

Step 4 – Download & Install Ogre Xcode Templates

Xcode templates are available for creating minimal Ogre3D Mac Projects. The Mac OS X Universal Precompiled Dependencies for OSX and iOS can be found of the SourceForge website. There are two installer versions available: the one that has Ogre templates for Xcode 3 and the other for Xcode 4. My directions are made for Xcode 3 so that is the Ogre template installer I’ll be using. I can’t tell you if my directions will work for Xcode 4 since I don’t have it to test against.
Ogre Xcode Templates Installer

Okay, so first thing is to download the Ogre Xcode template installer package. Visit the Ogre SourceForge Files website. Download the Ogre_Xcode_Templates_20101211.pkg.zip file to your Desktop or some other location on your Mac, extract the Ogre Xcode Templates Package from the zip file, and launch the installer by double-clicking on the package.

Select Ogre Install LocationOn Step 5 of the installer you’ll be asked for the paths to the OSX and iOS Ogre SDK locations. I haven’t discussed the iOS iPhone SDK release of Ogre and we’ve only installed the OSX version, so for now choose the Find Ogre button for the OSX option. Point to the /OgreSDK path (or to the location where you decided to install the Ogre SDK). Wrap up the rest of the installation by clicking Continue and finally Close.

Step 5 – Create a Mac OSX Ogre Project From The Xcode Template

Fire up Xcode and create a new Ogre3D project. You’ll notice on the left side there is now an Ogre section under User Templates. Click on Ogre and there are two template to choose from: iPhone OS and Mac OS X. I’m going to save the iPhone stuff for my next Ogre tutorial, so for now pick Mac OS X and click the Choose button. When the Xcode popup dialog appears point it to the location where you’d like to save your Ogre project and give it a name (e.g. OgreDemo).
Ogre Demo Xcode Project

You should now be looking at your Ogre Xcode Project. You may notice that there is some text in red (it indicates a problem). Basically, these files are broken, the paths don’t resolve. This is caused by a bug in the Ogre Xcode Templates. Step 6 below will resolve this issue. If you attempt to build the project, you’ll receive over 200 errors.

I recommend you familiarize with Xcode if you’ve never used it before. You can find documentation on the Apple Developer Website.  Follow this link for the User Guide – Xcode 4 User Guide: About Xcode 4.

Step 6 – Resolving the Ogre Xcode Template Bugs

This next phase deals with fixing some bugs that exist within the Ogre Xcode Templates. What we need to do is correct some Framework and .dylib paths, change the Mac Base SDK, Xcode project format, GCC compiler version, alter the header and library search paths, and make these changes permanent for future projects. Let’s get started.

1) Correct the Framework and .dylib paths – We’ll start with Cg.framework. Ctrl-click it and select Get Info. When the info box displays you’ll see the path is red. There is a Choose button to the far right of the window, click that and navigate to this file system path /Library/Frameworks and select Cg.framework then click the Choose button. On the info screen the path is now black. Hit the close button in the upper left of the window.

Cg.framework Info Window Cg.framework Info Window Details

Follow this same procedure for the following files:

  • Ogre.framework – /OgreSDK/lib/release/Ogre.framework
  • libOIS.a –  /OgreSDK/lib/release/libOIS.a
  • Plugin_CgProgramManager.dylib – /OgreSDK/lib/Plugin_CgProgramManager.dylib
  • Plugin_OctreeSceneManager.dylib – /OgreSDK/lib/Plugin_OctreeSceneManager.dylib
  • RenderSystem_GL.dylib – /OgreSDK/lib/RenderSystem_GL.dylib

2) Change the Mac Base SDK, Xcode project format, and GCC compiler version – Go to the Project menu and select Edit Project Settings option. On the info screen’s General tab, change the Xcode Project Format to Xcode 3.1-compatible and Base SDK for All Configurations to Mac OS X 10.6. Click on the Build tab, All Configurations, scroll down to the Compiler Version section, and for C/C++ Compiler Version change the value to System default (GCC 4.2). Close the info window.

Project OgreDemo Info GeneralProject OgreDemo Info Build

3) Alter the Header and Library Search Paths – Go back to the Project menu and select the Edit Active Target “Project Name” option (Project Name will be what you chose to name your project when you created it). Click on the Build tab, All Configurations, and scroll down to the Search Paths section. There are three lines we’re interested in: Framework Search Paths, Header Search Paths, and Library Search Paths. You’ll see that the paths prefix with _OGRESDK_ROOT_. This was supposed to be replaced with the Ogre SDK install location (aka /OgreSDK) you selected during the Xcode Template installation. To correct this we’ll edit each entry and replace _OGRESDK_ROOT_ with /OgreSDK. Close the window when you’re done.

Amendment – July 4, 2011

Change the boost headers directory from boost_1_42 to boost_1_46_1 in the header Search Paths. Thanks to Guido for pointing this out.

Target OgreDemo Info Build BeforeTarget OgreDemo Info Build After

That’s it for the changes. Build your project (Build menu -> Build and Run option). You shouldn’t receive any build errors (if you did, check all the setting changes from above and make sure you didn’t miss something). When the demo launches there will be a settings window, accept the defaults and click the OK button. Tada! It’s an Ogre!

Ogre MacOSX Demo Project Window

Press the Escape key to exit the Ogre3D program. There is still one last thing to do.

4) Make the Changes Permanent for Future Projects – The changes we’ve made are for this project only, so how do we apply them to any future projects created from the Ogre Xcode template? Luckily the solution is rather simple. Our modified project contains a settings file called project.pbxproj that holds the paths of all the frameworks, headers, libraries, and etc we applied as well as more information that isn’t relevant to our topic. All we have to do is copy the project.pbxproj file and overwrite the version that came with the Ogre Xcode Templates.

Open your Ogre project folder. Inside there is an item called PROJECT.xcodeproj (where PROJECT is the name of the project you created). Ctrl-click the xcodeproj and select Show Package Contents. Next copy the project.pbxproj file (ctrl-click, copy) and open a new Finder window. Navigate to the Ogre Xcode Templates file system path shown below.

/Library/Application Support/Developer/Shared/Xcode/Project Templates/Ogre/Mac OS X

MacOSX Finder Window Ogre Xcode Template File System Path
Here you’ll find the project template files that Xcode uses to create your Ogre3D projects. Move into the xcodeproj folder (ctrl-click, Show Package Contents) and paste the project.pbxproj you copied earlier. Replace the existing version. Technically we are done but we should change the file’s permissions to match.

MacOSX Terminal project.pbxproj Chown Permissions
Open a Terminal window (Applications -> Utilities -> Terminal). Navigate to the same Ogre Xcode Templates path from above. Change ownership of the project.pbxproj using the chown command. The full list of commands are show in the image.

computer:~ tony$ cd /Library/Application\ Support/Developer/Shared/Xcode/Project\ Templates/Ogre/Mac\ OS\ X/
computer:~ tony$ cd ___PROJECTNAME___.xcodeproj/
computer:~ tony$ sudo chown root:admin project.pbxproj

Amendment – July 4, 2011

In my haste of making this tutorial I didn’t completely test every aspect. The stricken out text above was for copying the OgreDemo project’s project.pbxproj settings file on top of the Ogre Xcode Project template’s version. The problem is that some settings then become hard-coded to use a file name of OgreDemo and the project won’t build unless it has the same exact name. Obviously that won’t work. You could rename but that defeats the purpose of a template. So we’ll be making modifications to the Ogre Xcode project template project.pbxproj directly this time around. We’re also going to bypass the copy, paste, ownership stuff, and use nano for editing to make the changes. Open a Terminal and issue the commands below.

computer:~ tony$ cd /Library/Application\ Support/Developer/Shared/Xcode/Project\ Templates/Ogre/Mac\ OS\ X/
computer:~ tony$ cd ___PROJECTNAME___.xcodeproj/
computer:~ tony$ sudo nano project.pbxproj

Make the following changes to the Ogre Xcode Template project.pbxproj settings file. I’ve included the line numbers for your information. To see what line number you’re on in nano, press ctrl-c. [ Control-C ]

MacOSX Ogre Xcode Template project.pbxproj nano

Replace libois.a with libOIS.a
[ Lines 16, 73, 98, 126 ]

Replace boost_1_42 with boost_1_46_1
[ Lines 311, 342 ]

Replace the path to Cg.framework _OGRESDK_ROOT_/Dependencies with /Library/Frameworks
[ Line 71 ]

Replace all _OGRESDK_ROOT_ with your Ogre SDK path /OgreSDK
[ Lines 72-73, 76-78, 299-300, 309-312, 318-320, 333-334, 340-343, 349-351 ]

Fix the Build Configurations (Debug & Release)
Change ARCHS = “$(ONLY_ACTIVE_ARCH_PRE_XCODE_3_1)”; to ARCHS = “$(ARCHS_STANDARD_32_BIT)”;
Change GCC_VERSION = 4.0; to GCC_VERSION = “”;
Change ONLY_ACTIVE_ARCH_PRE_XCODE_3_1 = “$(NATIVE_ARCH)”; to ONLY_ACTIVE_ARCH = YES;
Change SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk; to SDKROOT = /Developer/SDKs/MacOSX10.6.sdk;
[ Lines 360, 363, 366, 368 ] and [ Lines 375, 377, 380, 382 ]

Once you’ve made all the changes to the Ogre Xcode Template project.pbxproj, save the file by pressing ctrl-o. [ Control-O ] and ctrl-x [ Control-X ] to exit nano. Now any project created from the Ogre Xcode Templates will compile and from any name you save your project as.

That concludes this tutorial on installing the Ogre SDK 1.7.3 on a Mac OS X system. Any future Xcode projects you create using the Ogre Xcode Template won’t need changes to compile out the door. Stay tuned for more Ogre3D Mac articles from me.

This entry was posted in 3D Graphics, Apple, HOWTOs, MacOSX, Ogre3D and tagged , , , , , . Bookmark the permalink.

14 Responses to Guide to Installing Ogre3D on Mac OS X (Xcode + Ogre SDK 1.7.3)

  1. avatar omolina says:

    great! how to thanks …

    Very good tutorial.

  2. avatar m.suzuki says:

    Thank you very much. I could build Ogre project.

    I have an idea. After that, we might replace project name with ___PROJECTNAMEASIDENTIFIER___ in project.pbxproj.

  3. avatar Guido says:

    Really great. Saved me a lot of work. Well… it didn’t save me the work because I tried a different approach before doing this how to… but after I did those things and still couldn’t get ogre to work I know followed your how to and now it does work… So thanks….

    One minor thing; in step 6.3 when changing the header search paths you also have to change the path to [path to OgreSDK]/OgreSDK/boost_1_42 to [path to OgreSDK]/OgreSDK/boost_1_46_1

  4. avatar Aaal Goh says:

    Thanks a lot, Tony! Really clear and step-by-step instructions. :)

  5. avatar mate0b says:

    you can upload it? is very difficult for me to do all those things

  6. avatar John says:

    Thank you so much for posting such detailed instructions!

  7. avatar chaubold says:

    Thanks for the instructions! I spent two days now trying to build my own Ogre App on Mac but this is the first version where I actually can use mouse and keyboard input!

    I built my app with XCode 4, and the templates contain some errors as well. Again you have to: set the BaseSDK to Mac OSX 10.6, change the compiler to LLVM GCC 4.2 and – if you need it – add the Cg.framework. Pay attention to the OgreSDK path when creating the project btw, I started with ~/ and it put another slash in front which screwed up all the paths…

    Up to now you should be able to build the code, nevertheless the app won’t run as it does not copy the frameworks properly. What fixed it for me was changing the script in the build phase “run script” to the following.


    ditto /lib/release/Ogre.framework "$BUILT_PRODUCTS_DIR/appname.app/Contents/Frameworks/Ogre.framework"
    rm -r $BUILT_PRODUCTS_DIR/appname.app/Contents/Plugins
    ditto /lib/Render*.dylib "$BUILT_PRODUCTS_DIR/appname.app/Contents/Plugins/"
    ditto "$PROJECT_DIR/$PROJECT_NAME/media/" "$BUILT_PRODUCTS_DIR/appname.app/Contents/Resources/media/"
    ditto "/lib/release/Cg.framework" "$BUILT_PRODUCTS_DIR/appname.app/Contents/Frameworks/Cg.framework"
    ditto /lib/lib*.dylib "$BUILT_PRODUCTS_DIR/appname.app/Contents/Components/"
    ditto /lib/Plugin_*.dylib "$BUILT_PRODUCTS_DIR/appname.app/Contents/Plugins/"
    ditto $PROJECT_DIR/$PROJECT_NAME/*.cfg "$BUILT_PRODUCTS_DIR/appname.app/Contents/Resources/"

    Hope that saves some people the hassle I went through :)

  8. avatar chaubold says:

    Oh btw, I had to copy Cg.framework from /Library/Frameworks to somewhere else or it would say “access denied”. That’s why the path points to PATH_TO_OGRE_SDK as well.

    And I just noticed that it was stupid to put PATH_TO_OGRE_SDK in brackets as it got discarded while posting, so here’s the run script again. Remember to replace this and the appname placeholder for your app!


    ditto PATH_TO_OGRE_SDK/lib/release/Ogre.framework "$BUILT_PRODUCTS_DIR/appname.app/Contents/Frameworks/Ogre.framework"
    rm -r $BUILT_PRODUCTS_DIR/appname.app/Contents/Plugins
    ditto PATH_TO_OGRE_SDK/lib/Render*.dylib "$BUILT_PRODUCTS_DIR/appname.app/Contents/Plugins/"
    ditto "$PROJECT_DIR/$PROJECT_NAME/media/" "$BUILT_PRODUCTS_DIR/appname.app/Contents/Resources/media/"
    ditto "PATH_TO_OGRE_SDK/lib/release/Cg.framework" "$BUILT_PRODUCTS_DIR/appname.app/Contents/Frameworks/Cg.framework"
    ditto PATH_TO_OGRE_SDK/lib/lib*.dylib "$BUILT_PRODUCTS_DIR/appname.app/Contents/Components/"
    ditto PATH_TO_OGRE_SDK/lib/Plugin_*.dylib "$BUILT_PRODUCTS_DIR/appname.app/Contents/Plugins/"
    ditto $PROJECT_DIR/$PROJECT_NAME/*.cfg "$BUILT_PRODUCTS_DIR/appname.app/Contents/Resources/"

  9. avatar Julian Bitetto says:

    Some how, the ogre window doesn’t even pop up. This is very confusing for me even though I have followed every single instruction. There are no errors but the executable won’t show up when I run it! Please, I need help!

  10. avatar Julian Bitetto says:

    I get all this in my console when I build and run the program:

    [Session started at 2011-10-25 19:01:59 +1100.]
    dyld: lazy symbol binding failed: Symbol not found: __ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_i
    Referenced from: /Users/julian/Desktop/Stuff/OgreDemo/build/Debug/OgreDemo.app/Contents/MacOS/../Frameworks/Ogre.framework/Versions/1.7.3/Ogre
    Expected in: /usr/lib/libstdc++.6.dylib

    dyld: Symbol not found: __ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_i
    Referenced from: /Users/julian/Desktop/Stuff/OgreDemo/build/Debug/OgreDemo.app/Contents/MacOS/../Frameworks/Ogre.framework/Versions/1.7.3/Ogre
    Expected in: /usr/lib/libstdc++.6.dylib

    GNU gdb 6.3.50-20050815 (Apple version gdb-967) (Tue Jul 14 02:11:58 UTC 2009)
    Copyright 2004 Free Software Foundation, Inc.
    GDB is free software, covered by the GNU General Public License, and you are
    welcome to change it and/or distribute copies of it under certain conditions.
    Type “show copying” to see the conditions.
    There is absolutely no warranty for GDB. Type “show warranty” for details.
    This GDB was configured as “i386-apple-darwin”.sharedlibrary apply-load-rules all
    Attaching to process 1082.
    warning: Could not find object file “/Users/davidrogers/Documents/Ogre/ogre-v1-7-3/Dependencies/lib/libboost_thread-xgcc42-mt-1_46_1.a(thread.o)” – no debug information available for “libs/thread/src/pthread/thread.cpp”.

    warning: Could not find object file “/Users/davidrogers/Documents/Ogre/ogre-v1-7-3/Dependencies/lib/libboost_thread-xgcc42-mt-1_46_1.a(once.o)” – no debug information available for “libs/thread/src/pthread/once.cpp”.

    (gdb)

  11. avatar jokoon says:

    I’m having a hard time converting a MSVC app into xcode, biggest problems is making those paths work.
    I’m making my app from scratch btw, so it’s a little painful adding #ifdef __APPLE__ everywhere.

    I’m not done yet, but it seems your resource loader miss a “/Contents/Resources/”.

  12. avatar MettbrotPro says:

    Thank you for this great Tutorial.

Comments are closed.