Building From Source

From PyWiki

Jump to: navigation, search

For developers with more experience, building Python-OGRE from source is usually the more attractive option. For some, it is the only option as prebuilt binaries are not available. Source provides the fastest access to bug fixes and allows the developer to debug any aspect of their code or OGRE. It is also necessary for contributing patches. Select your platform and compiler from the list below. Then move on to learn how to setup your first application.

Contents

Building from Source

FIRST: Read this entire document. Be prepared to invest time into the setup of a build environment - there are numerous dependancies that you will need to collect and build before you can even start to play with the Python-Ogre build - be prepared to spend a good 3-4 hours (perhaps over a couple of days depending on update speeds) -- however, once it's done the updates and build of Python-Ogre are reasonably painless...

Requirements

Get everything listed here first!!

Building Boost

The indexing suite with boost (even the CVS) is ancient and you need to use the one included with Py++:

* copy pyplusplus_dev/indexing_suite_v2/src/indexing to boost/libs/python/src/indexing
* copy pyplusplus_dev/indexing_suite_v2/indexing to boost/boost/python/suite/indexing
* edit boost/libs/python/build/Jamfile.v2 -- add the following lines to the source list (after exec.cpp)
  * indexing/indexing_slice.cpp
  * indexing/python_iterator.cpp
* edit boost/tools/build/v2/user-config.jam to tell it what version of python you are using AND to specific the VC compiler as 7.1 (so the right library/dll file name is used)
#  Uncomment relevant parts to suite your local configuration and preferences.
import toolset : using ;
using python : 2.5 ;
using msvc : 7.1 ;
#  GCC configuration

Rebuild Boost

* cd boost/libs/python/build
* bjam release --V2

Note that it builds into boost/bin.v2/libs/python/build/....

Build the Source

Update PythonOgreConfig_xx.py to reflect your directory structure etc (where xx is 'nt' or 'posix' Under the code_generators directory you will find a seperate directory for each module (Ogre/CEGUI etc). In each directory there is a generate_code.py script that processes the appropiate header files (the first time this is run it builds an XML cache in the code_generators/cache directory) and dynamically builds the source code in the 'generated/ModuleName' directory. You run each of these generate_code.py scripts to dynamically create the source wrappers (that then get compiled into the python modules)

Also see LinuxNotes for help compiling in Linux or the Compiling On Mac OS X page.

Source Generating Files

 * generate_code.py:  Main program, builds the XML cache, creates source, handles exceptions
 * hand_made_wrappers.py :  Here is where we handle specials and wrappers that can't be automatically generated
 * python_module.h :  This is the 'main c++' compile file.  It includes the base headers for the module you are creating and exposes variables that won't normally get exposed

Compile the Source

Hint: With Windows you will need to run VCVARS32 in the DOS box before running scons

Use Scons... Run 'scons' from the 'root' directory (the one above "code_generators" etc)

ERRORS

There are plenty of things that can go wrong:

* Problems generating the wrapper source (generate_code.py)
* Problems with the compile
* Problems with link errors
* Problems when importing the Ogre library

However please ensure you have the LATEST of everything and everthing has been compiled :)

Problems with generate_code

If you have errors here it's either a screw up and the Python-Ogre SVN is broken, or (more likely) there is a mismatch happening between the library source code (Ogre) and the Python-Ogre SVN (generate_code). This often shows itself with errors like:

File "generate_code.py", line 905, in <module> generate_code()
File "generate_code.py", line 824, in generate_code  ManualExclude ( mb )
File "generate_code.py", line 150, in ManualExclude
global_ns.class_('::Ogre::SceneManager').mem_fun('getQueuedRenderableVisitor').exclude()
<.......>
  raise matcher.declaration_not_found_t( decl_matcher )
pygccxml.declarations.matcher.declaration_not_found_t: Unable to find declaration.  
matcher: [(decl type==member_function_t) and (name==getQueuedRenderableVisitor)]

FIX:

 * Ensure that you are up to date on everything and try again
 * Comment out the offending line in generate_code (!#150 in the example above)
 * Report the bug to the Python-Ogre mailing list and we'll get it fixed

Problems with Compiling

This doesn't happen often and means that we've generated bad code (which we shouldn't) so your only recourse is to report the bug (and you could look at the C source file in question and fix/comment out the problem area)

However, Ensure your compiler has the latest patches (MSVC 7.1 should be at SP1 or higher)

Problems with Linking

Module Specific Notes

Remember that boost needs RTTI data so enable this in your compiler for everything

Ogre

You now longer require any patches against the Ogre source under windows - however under Linux a couple of patches are required - check the LinuxNotes.

You may need this patch related to CompositorChains.

OgreNewt

Delete the 'boost' subdirectory from the OgreNewt_Main/inc directory - it's an older verison of boost and causes "interesting" problems. Ensure you add a path to your "CVS" version of boost to the build scripts

Get the OgreNewt.patch file (attached to this page - go to the bottom) and run it against the CVS version of Ogreaddons/OgreNewt

It removeds OgreNewt_BasicFrameListener from the OgreNewt.h include

Modifies OgreNewt_ContactCallback.h by removing the "protected" for variables m_material and m_contact.

Note that you should remove BasicFrameListener from the build scripts (under VC select BasicFrameListener.x from the source and header sections and delete them.

CEGUI

No changes to the source, however it needs to have RTTI enabled for the compile

OgreAL

No changes required - do check however that RTTI is enabled

OgreOde

The latest CVS now works with Ogre 1.4 so again no source changes - do check RTTI (did I say that already?)

Personal tools