Skip to main content

History: Building Ogre3D 1.9 Statically in Mac OS X (Yosemite)

Source of version: 29

Copy to clipboard
            The idea of this tutorial is to help you build Ogre3D 1.9 statically in Mac OS X (Yosemite). Additionally this tutorial will explain you how to run your first application from scratch using CMake and the QtCreator IDE. 

{maketoc}

! Prerequisites
*You need to have a basic C++ background.
*Basic knowledge about how to use a terminal in Mac OS X (create folders, list directory contents, run commands, etc.).
*An Internet connection (this sounds obvious, but it’s better to clarify :) ).
*Have the following software installed (there are no specific restrictions regarding the versions used, but it's better to use the latest):
**Xcode.
**Mercurial.
**QtCreator.
**CMake.   
*When this tutorial refers to the __terminal__, it's refering to the __Mac OS X Terminal__.
*When entering a command in the terminal, this tutorial refers to the current path location with the following notation:  
{CODE(ln=0, wrap="1", colors="c++")}
$> cd /folder1/folder2
/folder1/folder2 $> pwd
/folder1/folder2
{CODE}
---
! Building Ogre
First, create a folder where the whole Ogre3D project will live:
{CODE(wrap="1", colors="c++")}
$> sudo mkdir -p /opt/dev
{CODE}
You can create this folder in another location if you wish. This is not a blocker. The important thing is that you keep in mind where the folder was created to use it from now on.

!! Downloading Ogre3D’s Dependencies
Create the folder where the dependencies will reside:

{CODE(wrap="1", colors="c++")}/opt/dev/ $> mkdir dependencies{CODE}
Go to the following link and download ogre3D’s dependencies:

http://sourceforge.net/projects/ogre/files/ogre-dependencies-mac/1.9/OgreDependencies_OSX_libc%2B%2B_20130610.zip/download

Unzip the file you downloaded. This will contain a folder called __Dependencies__. Copy the content of that folder to the following location:

{CODE(wrap="1", colors="c++")}/opt/dev/dependencies{CODE}
You should have something like this:
{IMG(fileId="2214",rel="box[g]")}{IMG}
These dependencies include:

*__Boost: __It’s a set of open source libraries that extend the functionality of C++.
*__Freeimage:__ it’s an Open Source library project for developers who would like to support popular graphics image formats like PNG, BMP, JPEG, TIFF and others as needed by today's multimedia applications.
*__Freetype:__ It’s is a freely available software library to render fonts.
*__OIS:__ It’s a code library for constructing a human-computer interface with input devices such as a keyboard, mouse or game controller.
*__zlib:__ It’s a software library used for data compression.
*__zziplib:__ it offers the ability to easily extract data from files archived in a single zip file. 
The previous downloaded dependencies are static libraries (end up with the extension __.a__). Normally in other platforms when you build a library for 32 and 64 bits you end up with two different library files (one for 32 and other for 64). Here in Mac OS X, you can build for 32 AND 64 bits and you end up with a single file. That single file is what is called a “flat” binary or a “universal” binary. In order to check if a library is for 32 bits or 64 bits or both, just run the following command in a terminal:
{CODE(wrap="1", colors="c++")}/opt/dev/dependencies/lib/Release $> lipo -info libOIS.a
Architectures in the fat file: libOIS.a are: x86_64 i386{CODE}
!!Downloading and Building Ogre3D
it’s always better to use the latest stable version from the project’s repository. To do that you should use Mercurial (Mercurial is a distributed version control system). To validate if Mercurial is installed correctly, in a terminal write:
{CODE(wrap="1", colors="c++")}$> hg
Mercurial Distributed SCM

basic commands:

 add           add the specified files on the next commit
 annotate      show changeset information by line for each file
 clone         make a copy of an existing repository
 commit        commit the specified files or all outstanding changes
 diff          diff repository (or selected files)
 export        dump the header and diffs for one or more changesets
 forget        forget the specified files on the next commit
 init          create a new repository in the given directory
 log           show revision history of entire repository or files
 merge         merge working directory with another revision
 pull          pull changes from the specified source
 push          push changes to the specified destination
 remove        remove the specified files on the next commit
 serve         start stand-alone webserver
 status        show changed files in the working directory
 summary       summarize working directory state
 update        update working directory (or switch revisions)

use "hg help" for the full list of commands or "hg -v" for details
{CODE}
To download the Ogre3D's code, write in a terminal:
{CODE(wrap="1", colors="c++")}$> cd /opt/dev
/opt/dev/ $> hg clone https://bitbucket.org/sinbad/ogre ogre3d-1.9.0{CODE}
The last part of the previous command (__ogre3d-1.9.0__) will be the name of the folder where the source code will be downloaded. The download process will take something like 20 minutes (although it depends of your Internet connection).
If everything went okay, the folder should be around 460 MB:
{CODE(wrap="1", colors="c++")}opt/dev/$> du -sh /opt/dev/ogre3d-1.9.0/
461M	/opt/dev/ogre3d-1.9.0/{CODE}
Now it's time to build Ogre3D statically (before running the __cmake__ command, validate that your paths are consistent. After that, just build):
{CODE(wrap="1", colors="c++")}/opt/dev/ogre3d-1.9.0 $> mkdir build
/opt/dev/ogre3d-1.9.0 $> cd !$
/opt/dev/ogre3d-1.9.0/build $> cmake -DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} -v -stdlib=libc++ -std=c++11" -D BOOST_ROOT=/opt/dev/dependencies/include/boost -D BOOST_INCLUDEDIR=/opt/dev/dependencies/include/boost -D BOOST_LIBRARYDIR=/opt/dev/dependencies/lib -D OGRE_DEPENDENCIES_DIR=/opt/dev/dependencies -D OGRE_STATIC=1 -D OGRE_BUILD_SAMPLES=1 -G Xcode ..{CODE}
Here is the explanation for every command:
{FANCYTABLE( head="__Command__|__Description__")}
CMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} -v -stdlib=libc++ -std=c++11”   |   Defines support for C++11.
BOOST_ROOT=/opt/dev/dependencies/include/boost|   Defines the location of the Boost base folder.
BOOST_INCLUDEDIR=/opt/dev/dependencies/include/boost|Defines the location of the Boost’s include folder.
BOOST_LIBRARYDIR=/opt/dev/dependencies/lib|Defines the location of the Boost’s library folder.
OGRE_DEPENDENCIES_DIR=/opt/dev/dependencies|Defines the location of the Ogre3D’s dependencies folder.
OGRE_STATIC=1|Defines that Ogre3D will be built statically. 
OGRE_BUILD_SAMPLES=1|Defines that the Ogre3D’s samples will be built.
-G Xcode|Specify a makefile generator (Xcode in this case).
..|The couple of dots indicate the location of the CMakeLists.txt file (which is the file that cmake needs to create all the make files). 
{FANCYTABLE}
After building Ogre3D you’re going to end with the following files:
{CODE(wrap="1", colors="c++")}/opt/dev/ogre3d-1.9.0/build $> ls -l OGRE.*
OGRE.build:
total 0
drwxr-xr-x  5 USER  wheel  170 Dec  8 19:14 Debug
drwxr-xr-x  6 USER  wheel  204 Dec  8 19:22 Release

OGRE.xcodeproj:
total 5400
-rw-r--r--  1 USER  wheel  2763182 Dec  8 19:05 project.pbxproj
drwxr-xr-x  4 USER  wheel      136 Dec  8 19:14 project.xcworkspace
drwxr-xr-x  3 USER  wheel      102 Dec  8 19:14 xcuserdata{CODE}
The OGRE.xcodeproj file is the Xcode project configuration file for the Ogre3D’s construction. Go to Finder and double click over that file. This will open Xcode.

Note: This tutorial will use Xcode only to build Ogre3D. Afterwards you’re not going to use it anymore.

This is what you’re going to see when Xcode opens with the Ogre3D project:
{IMG(fileId="2215",rel="box[g]", thumb="y")}{IMG}


        

History

Information Version
Tue 03 of Feb, 2015 02:31 GMT-0000 Netheril 110
Tue 03 of Feb, 2015 02:28 GMT-0000 Netheril 109
Tue 03 of Feb, 2015 02:28 GMT-0000 Netheril 108
Sun 14 of Dec, 2014 00:04 GMT-0000 Netheril 107
Fri 12 of Dec, 2014 03:14 GMT-0000 Netheril 106
Fri 12 of Dec, 2014 02:50 GMT-0000 Netheril 105
Fri 12 of Dec, 2014 02:50 GMT-0000 Netheril 104
Fri 12 of Dec, 2014 02:49 GMT-0000 Netheril 103
Fri 12 of Dec, 2014 02:49 GMT-0000 Netheril 102
Fri 12 of Dec, 2014 02:37 GMT-0000 Netheril 101
Fri 12 of Dec, 2014 02:24 GMT-0000 Netheril 100
Fri 12 of Dec, 2014 02:04 GMT-0000 Netheril 99
Fri 12 of Dec, 2014 01:37 GMT-0000 Netheril 98
Fri 12 of Dec, 2014 01:21 GMT-0000 Netheril 97
Fri 12 of Dec, 2014 01:17 GMT-0000 Netheril 96
Fri 12 of Dec, 2014 01:17 GMT-0000 Netheril 95
Fri 12 of Dec, 2014 01:17 GMT-0000 Netheril 94
Fri 12 of Dec, 2014 01:15 GMT-0000 Netheril 93
Fri 12 of Dec, 2014 01:07 GMT-0000 Netheril 92
Fri 12 of Dec, 2014 01:06 GMT-0000 Netheril 91
Fri 12 of Dec, 2014 01:03 GMT-0000 Netheril 90
Fri 12 of Dec, 2014 01:00 GMT-0000 Netheril 89
Fri 12 of Dec, 2014 00:59 GMT-0000 Netheril 88
Fri 12 of Dec, 2014 00:52 GMT-0000 Netheril 87
Fri 12 of Dec, 2014 00:47 GMT-0000 Netheril 86