Requirements
To perform the tasks described in this tutorial it is necessary for you to setup a basic development system including:
- Developer tools for Mac OSX (XCode 3.1.2 or later)
- Eclipse (3.4 or later) and Eclipse CDT plugin (downloadable from eclipse official update site) or directly Eclipse for C/C++ Developers version
- Ogre pre built SDK (1.6 or later)
To create your first application start Eclipse and select New -> C++ Project from the File menu.
Now select Hello World C++ Project and give it a name (let's say MyFristOgreApp).
Application configuration
The application is now created, but is not connected in any way to Ogre, thus any ogre specific code, if compiled, would give compilation, link and run-time errors.
To solve this problem you have to include the Ogre framework in your application, and make the project aware of the Ogre and Carbon frameworks position.
- Right-click on your project name in the Project Explorer and select Import, then select import from File System.
Browse to the Dependencies directory of the OgreSDK folder, select the subfolders and then import it in the Frameworks subdir for your project. - Now right-click again on your project name in the Project Explorer and select Properties.
Move to C/C++ General -> Paths and Symbols and press the Add button.
Select Frameworks/Ogre.framework/Header directory in you workspace and check Add to all configurations, Add to all languages and Is a workspace path.
Do the same for Frameworks/Cg.framework/Header and Frameworks/include directories.
Press Add again, select /Developer/Headers/FlatCarbon folder and check only Add to all configurations, Add to all languages this time. - Move to Library Paths tab and press Add; again check Add to all configurations, Add to all languages and Is a workspace path and add Framworks/lib/Release directory.
- Now select C/C++ Build ->Settings from the tree menu on the left and set the configuration selector to [ All configurations ].
Click on C++ Linker -> Libraries and add ois to Libraries - Finally click on C++ Linker -> Miscellaneous and write -F${CWD}/../Frameworks -framework Ogre -framework Carbon -framework IOKit -framework Cg in the Linker flags text box.
Now your IDE is correctly configured but your application will not compile due to an error within the Frameworks/Ogre.framework/Headers/OSX/OgreTimerImp.h file. Edit this file and change the line #include <ogre/OgrePrerequisites.h> to #include <OgrePrerequisites.h>.
Conclusion and last hints
Now this setup will allow you to compile any Ogre based application, however, if you want to work with Ogre official tutorials, you have to go through some further steps:
- Import in you application the headers required by the tutorial you are working on (most of the times ExampleApplication.h and ExampleFrameListener.h are required).
You can find them in the Samples directory of your OgreSDK. - Import the Media directory of your OgreSDK into your project's root (this directory contains all the tutorials required textures, models, etc... )
- Import the .cfg files from you OgreSDK and modify them to match the path of your Media directory (typically ../Media is good).
- Add this command: install -d ${CWD}/Contents/Resources && cp -f ${CWD}/../*.cfg ${CWD}/Contents/Resources to your project's Post-build step (set it in the Build steps tab of the C/C++ Build -> Settings configuration form and remember to do it for all configurations)
6 comments:
Found this through the Ogre3d Forums. I was looking for something like this for a while now. Thanks for sharing your insight.
Hi This really helped. But I have a question
The ois library is named libois.a in the Dependencies.
Do i need to include ois in the linker or do I need to
include libois or libois.a.
when i just type ois. The Project cant find the ois
g++ -L"" -F/Users/evrenbingol/GameDevelopment/Games/1935/Debug/../Frameworks -framework Ogre -framework Carbon -framework IOKit -framework Cg -o "1935" ./src/1935.o -lois
ld: library not found for -lois
collect2: ld returned 1 exit status
make: *** [1935] Error 1
this is the error And the project is called 1935.
Thanks
E.B
I forgot to mention that
i know that lib is attached automatically
so it should just be ois. Could there be any reasons
that you can think of
I found out why .
I need to add all the libraries and header as a relative path not by "File System" but by "Workspace"
When compiling i get errors. -> Ogre.framework/Ogre, file was built for i386 which is not the architecture being linked (x86_64). I use I386 Eclipse. Where do i have to set the architecture ??? All files are I386 !!
Found the Problem with the architecture. You have to set the Flag "-m32" to get it working.
Post a Comment