OSXBuild

From PyWiki

(Redirected from CompilingOnMacOSX)
Jump to: navigation, search

Contents

How to build python-ogre on a Mac

Please Note: this page is now out of date and needs an update :)

Please see the newer instructionsOSXBuildV2

This is a step by step instruction on how to build python-ogre on Mac OS X.

What you need

  • an Intel Mac with OS X version 10.4.x
  • XCode 2.4.1

(at least that's what I am using, maybe it will work on another setup as well)

  • a (fast) internet connection
  • root (sudo) access on your machine
  • /usr/local/bin in your PATH
  • approximately 5 GB of free disc space
  • quite some time and a lot of nerves

Most of the sources are the latest development versions grabbed via svn or cvs. Therefore, the following steps might not work exactly the same way on later versions due to the changes made since today (March, 18th 2007).

To make the downloading process easier, you might want to download and install wget:

If you don't want to download and compile the sources manually, you could try out my script ScriptForPythonOgreOnMac

Downloading

  • download and install svn
 wget http://metissian.com/downloads/macosx/subversion/subversion-client-1.3.1.dmg
 open subversion-client-1.3.1.dmg
  • download Ogre from cvs
 cvs -d:pserver:anonymous:@cvs.ogre3d.org:/cvsroot/ogre login
 cvs -z3 -d:pserver:anonymous@cvs.ogre3d.org:/cvsroot/ogre co -P ogrenew    
  • download and install the Ogre Dependencies
 wget http://downloads.sourceforge.net/ogre/Eihort_Universal_Dependencies_beta_2.zip
 unzip Eihort_Universal_Dependencies_beta_2.zip
 mv Eihort_Universal_Dependencies_beta_2/Dependencies ogrenew
 mv Eihort_Universal_Dependencies_beta_2/Frameworks/*.framework ~/Library/Frameworks
 rm -rf Eihort_Universal_Dependencies_beta_2
  • download py-ogre from svn
 svn co https://python-ogre.svn.sourceforge.net/svnroot/python-ogre/trunk/python-ogre python-ogre
  • download and install Python 2.5 for Macintosh OS X (framework version)
 wget http://www.python.org/ftp/python/2.5/python-2.5-macosx.dmg
  • download OIS
 wget http://downloads.sourceforge.net/wgois/ois-1.0RC1.tar.gz
 tar zxvf ois-1.0RC1.tar.gz
  • download scons
 wget http://prdownloads.sourceforge.net/scons/scons-src-0.96.95.tar.gz
 tar xvzf scons-src-0.96.95.tar.gz
  • download GCC_XML from cvs
 cvs -d :pserver:anoncvs:@www.gccxml.org:/cvsroot/GCC_XML login
 cvs -d :pserver:anoncvs@www.gccxml.org:/cvsroot/GCC_XML co gccxml
  • download pygccxml from svn
 svn co https://pygccxml.svn.sourceforge.net/svnroot/pygccxml pygccxml
  • download boost from cvs
 cvs -d:pserver:anonymous:@boost.cvs.sourceforge.net:/cvsroot/boost login 
 cvs -z3 -d:pserver:anonymous@boost.cvs.sourceforge.net:/cvsroot/boost co -P boost

Patching

  • copy the py++ indexing suite to the boost indexing suite
 cp -rf pygccxml/pyplusplus_dev/indexing_suite_v2/src/indexing boost/libs/python/src
 cp -rf pygccxml/pyplusplus_dev/indexing_suite_v2/indexing boost/boost/python/suite/
  • change boost/libs/python/build/Jamfile.v2 to include the python indexing suite
#!cpp
   [...]
   exec.cpp
   indexing/indexing_slice.cpp
   indexing/python_iterator.cpp
   [...]
  • change ogrenew/OgreMain/include/!OgreSearchOps.h to include only once
#!cpp
   #ifndef __SearchOps_H__
   #define __SearchOps_H__
   
   [...]
   
   #endif
  • change ogrenew/Mac/Ogre/include/config.h to avoid some nasty warnings
#!cpp
   /* snprintf */
   #ifndef HAVE_SNPRINTF
   #define HAVE_SNPRINTF
   #endif 
  • add self-link in ogrenew/OgreMain/include so that wrapper generation is happier
   cd ogrenew/OgreMain/include
   ln -s . Ogre
   cd ../../..
  • change python-ogre/PythonOgreConfig_posix.py to reflect your setup
#!python
import sys,os

SRC_BASE          = '/Users/kodi/Projects/ogre' # change this to the path where you downloaded the sources

print "SRC_BASE", SRC_BASE
## Boost stuff 
## path to the root of your boost dir, should have 'libs', 'boost' subdirectories
PATH_Boost        = os.path.join( SRC_BASE, 'boost')    
## Path to your boost_pythonxxxx lib file
PATH_LIB_Boost    = os.path.join( PATH_Boost, 'bin.v2/libs/python/build/darwin/release/')
## and the name of the boost python library
LIB_Boost         = r'boost_python-1_35'
## Ogre Home, should 'Samples', 'OgreMain' subdirectories
PATH_Ogre         = os.path.join( SRC_BASE, 'ogrenew')
PATH_OgreAddons   = os.path.join( SRC_BASE, 'ogreaddons')

PATH_CEGUI        = r # os.path.join( SRC_BASE, 'CEGUI-0.5.0')
PATH_OIS          = os.path.join( SRC_BASE, 'ois-1.0RC1')
PATH_Newton       = os.path.join( SRC_BASE, 'NewtonSDK/sdk') 

# Don't forget we need to call gccxml......
gccxml_bin        = os.path.join( SRC_BASE, 'gccxml/GCC_XML/') 
# and the Py++ directory as sometimes we need access to the code repository there
pyplusplus_install_dir = os.path.join( SRC_BASE, 'pygccxml')

## Parent directories of the libraries
PATH_FMOD         = SRC_BASE
PATH_ODE          = os.path.join( SRC_BASE, 'ode')
PATH_OGREAL       = SRC_BASE
PATH_OGG          = SRC_BASE
PATH_VORBIS       = SRC_BASE
PATH_OPENAL       = SRC_BASE
PATH_ALUT         = SRC_BASE
PATH_OgreOde      = os.path.join( PATH_OgreAddons, 'ogreode')

# Overrides - this is needed as libs isn't defined in enirvonment for fmod..
class fmod:
   version= "4.06"
   libs=[LIB_Boost, 'fmodexL_vc']
   ##libs=[Config.LIB_Boost, 'libfmodex']  ##posix

###
### these paths assume you've left all the directory structure as standard
### Override anything that is different
###        
PATH_LIB_Ogre_CEGUIRenderer     = os.path.join(   PATH_Ogre,      'Samples/Common/CEGUIRenderer/lib')
PATH_LIB_Ogre_OgreMain          = os.path.join( PATH_Ogre,      'OgreMain/lib/Release' )
PATH_LIB_Ogre_Dependencies      = os.path.join( PATH_Ogre,      'Dependencies/lib/Release')
PATH_LIB_OgreRefApp             = os.path.join( PATH_Ogre,      'ReferenceApplication/ReferenceAppLayer/lib/Release')
PATH_LIB_OgreNewt               = os.path.join( PATH_OgreAddons,'ogrenewt/build/OgreNewt_Main') 
PATH_LIB_Newton                 = PATH_Newton
PATH_LIB_OIS                    = PATH_LIB_Ogre_Dependencies
PATH_LIB_CEGUI                  = os.path.join( PATH_Ogre,      'Dependencies/lib/Release' )
PATH_LIB_ODE                    = '/usr/local/lib'
PATH_LIB_OgreOde                = os.path.join( PATH_OgreOde,   'lib/Release') 
PATH_LIB_OgreOdePrefab          = os.path.join( PATH_OgreOde,   'prefab/lib/Release' )
PATH_LIB_OgreOdeLoader          = os.path.join( PATH_OgreOde,   'loader/lib/Release' )

PATH_LIB_FMOD                   = os.path.join( PATH_FMOD,      'api/lib') 
PATH_LIB_OgreAL                 = os.path.join( PATH_OGREAL,    'lib/Release' )


PATH_INCLUDE_Ogre               = os.path.join( PATH_Ogre,      'OgreMain/include') 
PATH_INCLUDE_Ogre_Dependencies  = os.path.join( PATH_Ogre,      'Dependencies/include')
PATH_INCLUDE_OIS                = os.path.join( PATH_OIS,       'includes')    ## Note the plural include's
PATH_INCLUDE_OgreRefApp         = os.path.join(   PATH_Ogre,      'ReferenceApplication/ReferenceAppLayer/include') 
PATH_INCLUDE_OgreNewt           = os.path.join( PATH_OgreAddons,'ogrenewt/OgreNewt_Main/inc')
PATH_INCLUDE_CEGUI              = os.path.join( PATH_CEGUI,     'include/CEGUI')
PATH_INCLUDE_ODE                = '/usr/local/include'
PATH_INCLUDE_ODESOURCE          = os.path.join( PATH_ODE,       'ode/src')
PATH_INCLUDE_OgreAL             = os.path.join( PATH_OGREAL,    'include' )
PATH_INCLUDE_OPENAL             = os.path.join( PATH_OPENAL,    'include')
PATH_INCLUDE_OGG                = os.path.join( PATH_OGG,       'include' )
PATH_INCLUDE_VORBIS             = os.path.join( PATH_VORBIS,    'include' )
PATH_INCLUDE_ALUT               = os.path.join( PATH_ALUT,      'include' )

PATH_INCLUDE_OgreOde            = os.path.join( PATH_OgreOde,   'include')
PATH_INCLUDE_OgreOdePrefab      = os.path.join( PATH_OgreOde,   'prefab/include')
PATH_INCLUDE_OgreOdeLoader      = os.path.join( PATH_OgreOde,   'loader/include')

PATH_INCLUDE_FMOD               = os.path.join( PATH_FMOD,      'api/inc')
PATH_INCLUDE_Ogre_CEGUIRenderer = os.path.join(  PATH_Ogre,      'samples/Common/CEGUIRenderer/include')
   

Building

  • build Ogre
 xcodebuild -project ogrenew/Mac/Ogre/Ogre.xcodeproj -configuration Debug

how to build ogre on mac is described here: http://www.ogre3d.org/wiki/index.php/Building_From_Source#Mac_OS_X

  • build bjam
 cd boost
 ./configure
 cp user-config.jam tools/build/v2
 cp tools/jam/src/bin.macosxx86/bjam /usr/local/bin/
 cd ..
  • build boost.python
 cd boost/libs/python/build
 bjam -d+2 release --V2
 cd ../../..
 sudo cp bin.v2/libs/python/build/darwin/release/libboost_python-1_35.dylib /usr/local/lib/
 cd ..
  • build pygccxml
 cd pygccxml/pygccxml_dev
 python setup.py build
 sudo python setup.py install
 cd ../..
  • build py++
 cd pygccxml/pyplusplus_dev
 python setup.py build
 sudo python setup.py install
 cd ../..
  • build GCC_XML
 mkdir gccxml-build
 cd gccxml-build
 cmake ../gccxml
 make
 make install
 cd ..
  • build scons
 cd scons-src-0.96.95
 python bootstrap.py build/scons
 export SCONS_LIB_DIR=`pwd`/src/engine
 python src/script/scons.py build/scons
 cd build/scons
 sudo python setup.py install
 cd ../../..
  • generate ogre wrappers
 cd python-ogre/code_generators/ogre
 python generate_code.py
 cd ../../..
  • generate OIS wrappers
 cd python-ogre/code_generators/ois  
 python generate_code.py
 cd ../../..
  • build python-ogre
 cd python-ogre
 scons PROJECTS=ogre,ois
 cd ..

Installing

  • change the python-ogre/setup.py script to include only Ogre and OIS (After much ballyhoo, I did =svn revert setup.py= and backed out the suggested change here. Also, there were several lines in some of the generated sources that wouldn't compile. I just harshly =ifdef=-ed them out. I can run the demos now. Yay. -- pat at nklein_com)
PACKAGEDATA = {
      "packages":    ['Ogre', 'OIS'],
      "package_dir": {: 'packages'},
      "package_data": {: ['*.pyd', '*.dll', '*.so']},
  • install the packages
 cd python-ogre
 sudo python setup.py install
 cd ..

Running the Demos

  • change the python-ogre/demos/ogre/plugins.cfg file:
# Defines plugins to load
Plugin=RenderSystem_GL
Plugin=Plugin_ParticleFX
Plugin=Plugin_BSPSceneManager
Plugin=Plugin_OctreeSceneManager
Plugin=Plugin_CgProgramManager
  • change the python-ogre/demos/ogre/ogre.cfg file (important is RTT Preferred Mode=PBuffer)
Render System=OpenGL Rendering Subsystem

[OpenGL Rendering Subsystem]
Colour Depth=32
FSAA=0
Full Screen=No
RTT Preferred Mode=PBuffer
Video Mode=1024 x 768
Personal tools