Python-Ogre install on Ubuntu 14.04

anderen2

14-09-2014 02:25:26

I noticed that many people have issues getting Python-Ogre to work on Ubuntu/Linux, and my old 32-bit build notes did not "work" anymore (They never really worked in the sense of working good). Therefor I took it upon myself as a weekend project to get this to compile, as I got tired of working with programming a 32-bit project on an 64-bit system. And, well, I haven't been compiling much in my life (Which is also why I'm using python-ogre), but I doubt I will come across something with as much resistance to get compiled and working as this. Used 2 days, as well as my previous notes in my previous thread (Which really brings it up to 4 days), working on getting this to compile, and at the end it paid off.

I can now provide three ways of getting Python-Ogre to work on Ubuntu/Linux, I present the Good, the Bad and the Ugly way of getting Python-Ogre to work.

The "Good" (As in install a package, the good old Linux way):
I made a deb-package for python-ogre which you could get here: http://greker.org/and/pyogre/python-ogre_1.0-0.7.deb
While you are downloading that, you need these dependencies to install the package: libboost-python1.54.0 libboost-thread1.54.0 libboost-system1.54.0 libfreeimage3 libzzip-0-13 libcg
For the new to Linux, this is all you need to do to install this way:
sudo apt-get install libboost-python1.54.0 libboost-thread1.54.0 libboost-system1.54.0 libfreeimage3 libzzip-0-13 libcg
sudo dpkg -i python-ogre_1.0-0.7.deb



The "Bad"
(As in pray to the Linux demons for mercy on your soul, and compile while jumping hoops and sweating):
Well, you chose the dark side, I do hope you are a masochist because here it goes:
NB: I am not an experienced compiler/builder/linker/etc, the steps here might be redundant, and they might also not even be right, but if you spot an error then please say so!
NBNB! Some of these steps actually requires system-level changes, so I would recommend doing this in an virtual machine.

Step 1: Prepare build environment

Get dependencies
Many necessary dependencies are missing from 00-PreReq and many will not compile with the BuildModule script.
# Get stuff from the 00-PreReqs manually
sudo apt-get install automake1.9 libgl1-mesa-dev libx11-dev freeglut3-dev libtool libxaw7-dev libxxf86vm-dev patch libxrandr-dev cvs libxt-dev libexpat1-dev python-dev libglew-dev jam cmake libboost-thread-dev libboost-date-time-dev scons libfreeimage-dev libfreeimage3 libzzip-dev g++ libfreetype6-dev libpcre3-dev autoconf

# Get additional dependencies (See http://www.cse.unr.edu/~lagoon/index.ph ... untu_12.04)
sudo apt-get install subversion libglew1.6-dev python-yaml libglm-dev libglfw-dev libcg nvidia-cg-toolkit gccxml libboost-python-dev

#Get additional dependencies
sudo apt-get install gcc-4.6 g++-4.6 libx11-6 libx11-dev libboost1.49-dev libboost-all-dev gccxml


Get it all
Download everything you need to compile
svn co https://python-ogre.svn.sourceforge.net ... hes/v1-6-4 python-ogre


Fix compiler issues
For some reason unknown to me I was not able to compile Ogre with the latest gcc and g++, therefor replacing it with the 4.6 version
cd /usr/bin; sudo mv gcc gccBCK; sudo mv g++ g++BCK; sudo cp gcc-4.6 gcc; sudo cp g++-4.6 g++

Fix BuildModule.py errors
Hydrax does not exist in the archive, but is present in environment.py. Removing it from environment.py.
Also BuildModule.py has some linker errors (I think), replace it with my custom

sed -i.bak -e '1877d' python-ogre/environment.py
Replace python-ogre/BuildModule.py with this: http://greker.org/and/pyogre/BuildModule.py


Download and build additional dependencies
The repo version of these does not work when building python-ogre for some reason, building them from source.
python python-ogre/BuildModule.py -r pyplusplus
python python-ogre/BuildModule.py -b pyplusplus --usesystem
python python-ogre/BuildModule.py -r pygccxml
python python-ogre/BuildModule.py -b pygccxml --usesystem


Step 2: Build OIS

Download and configure OIS
python python-ogre/BuildModule.py -r ois
cd ois; ./bootstrap
./configure --prefix=/usr --includedir=/usr/include


Fix OIS makefiles
Unsure if this step is really necessary, but adding it nevertheless as I got it building this way.
#Change the line LIBS= to:
LIBS = -Xlinker -lboost_thread -lboost_system -lboost_python -lpthread -ldl
in ois/Makefile and ois/src/Makefile


Fix OIS headers
These headers were missing the first time I built OIS, but was there this time. Adding this step for good measure anyway.
The following lines should go into ois/src/linux/LinuxJoyStickEvents.cpp
#include <linux/input.h>
#include <unistd.h>


Make'n'Build OIS
make; sudo make install; cd ..

Step 3: Build Ogre

Download and decompress
python python-ogre/BuildModule.py -r ogre
cd downloads; tar jxf ogre*
mv ogre* ../ogre


Configure stuff
Seems like libfreetype changed paths since the buildscript was made. Using cmake to add the new path
export CXX=g++-4.6
cd ogre; cmake . -DOGRE_INSTALL_PLUGINS_HEADERS=TRUE -DCMAKE_INSTALL_PREFIX:PATH=/usr -DFREETYPE_LIBRARY=/usr/lib/x86_64-linux-gnu/libfreetype.so -DFREETYPE_INCLUDE_DIR=/usr/include/freetype2


Fix stuff
I encountered a lot of issues with compiling ogre, and later linking ogre with python-ogre. I chose to remove Sample_Browser and Ogre Tools from the compilation as I did not want to waste time debugging why they did not want to compile/link with my new shiny flags.
Comment out add_subdirectory(Browser) in ogre/Samples/CmakeLists.txt
Comment out add_subdirectory(Tools) in ogre/CmakeLists.txt


Ogre compiles fine without the following flags, but when later running python-ogre with plugins it will crash as it does not find the symbol: _ZTIN5boost6detail16thread_data_baseE
Edit target_link_libraries in all these:
anderen2@vbox-xubuntu64:~/build/ogre$ find . | grep CMakeLists.txt | grep -v Samples
./CMakeLists.txt
./PlugIns/CMakeLists.txt
./PlugIns/OctreeSceneManager/CMakeLists.txt
./PlugIns/OctreeZone/CMakeLists.txt
./PlugIns/ParticleFX/CMakeLists.txt
./PlugIns/BSPSceneManager/CMakeLists.txt
./PlugIns/CgProgramManager/CMakeLists.txt
./PlugIns/PCZSceneManager/CMakeLists.txt
./Components/CMakeLists.txt
./Components/Paging/CMakeLists.txt
./Components/Property/CMakeLists.txt
./Components/RTShaderSystem/CMakeLists.txt
./Components/Terrain/CMakeLists.txt
./Docs/CMakeLists.txt
./Tests/CMakeLists.txt
./Tests/PlayPen/CMakeLists.txt
./OgreMain/CMakeLists.txt
./Tools/XMLConverter/CMakeLists.txt
./Tools/CMakeLists.txt
./Tools/MeshUpgrader/CMakeLists.txt
./CMake/CMakeLists.txt
./CMake/Templates/SDK_CMakeLists.txt.in
./RenderSystems/Direct3D10/CMakeLists.txt
./RenderSystems/CMakeLists.txt
./RenderSystems/Direct3D9/CMakeLists.txt
./RenderSystems/GLES/CMakeLists.txt
./RenderSystems/GL/CMakeLists.txt
./RenderSystems/GL/CMakeLists.txt.save
./RenderSystems/Direct3D11/CMakeLists.txt

to be:

target_link_libraries(RenderSystem_GL OgreMain ${OPENGL_LIBRARIES} ${PLATFORM_LIBS} -Xlinker -lboost_thread -lboost_system -lboost_python -lpthread)


Make and build
make; sudo make install

Step 4: Build Python-Ogre

Replace some stuff
wget greker.org/and/pyogre/SConstruct
Replace with the one in python-ogre/


Generate some code
python python-ogre/BuildModule.py -g ogre --usesystem

Compile Python-Ogre
cd python-ogre; scons -j2 PROJECTS=ogre .

Build and build again(?)
The _ZTIN5boost6detail16thread_data_baseE issue again
Unsure if this step is redundant after doing the above, but here goes. I am not going to post a wall of text (Atleast not a bigger wall than this is already), so I made the following command into a script.
wget greker.org/and/pyogre/gigalink
chmod +x ./gigalink
./gigalink


Step 5: OIS? Again?
Yes. Unsure if I have to do it in this specific line of order, but here goes.

Simple enough
#Wrap it
python python-ogre/BuildModule.py -g ois --usesystem
#'n Push it
python python-ogre/BuildModule.py -c ois --usesystem


Step 6: Build CEGUI

Download, extract and configure
python python-ogre/BuildModule.py -r cegui --usesystem
cd downloads; tar xvfz CEGUI*; mv CEGUI* ../cegui; cd ..
cd cegui; ./configure --prefix=/usr --includedir=/usr/include


Fix stuff again
Add the following to cegui/include/CEGUIString.h
#include <cstddef>

Change makefile, edit lines to be:
LIBS = -Xlinker -lboost_thread -lboost_system -lboost_python -lpthread -ldl
SUBDIRS = . cegui datafiles doc projects


Makin'n'Bakin'
Yes, I know my titles are getting more and more ridiculous, but this is because the clock is getting more and more close to the time I usually wake up
make && sudo make install

Generate and Compile
python python-ogre/BuildModule.py -g cegui --usesystem
python python-ogre/BuildModule.py -c cegui --usesystem


Step 10: Congratulations, you are now the father of a new born python module

Install
Run this last bit of code to install the rest onto your system
python python-ogre/BuildModule.py -b install --usesystem
If for some reason this guide does not work, feel free to send me a PM and I will help you to the best of my knowledge. Also, links to my buildnotes, bash_history, and edited files are below if you want to see how I came up with the solution.

http://greker.org/and/pyogre/


The "Ugly"
(As in the original hackish way):
This is one of the ugliest hacks I've ever built a project on, and I recommend this to no-one. But it is an solution aswell, and if the two above for you is unreasonable or not working for some reason, then well, who am I to blame you.

This solution works by giving you a second, isolated 32-bit python installation on your system, meaning only the modules provided with it will work (Unless you manually add more). The modules provided are: Ogre, CEGUI, OIS, CG, twisted, wxPython, zope. This means that every new python-module you later want to include in your project using this method will have to be manually installed and included (Which is a pain for some modules).

All you have to do for this solution to work is to:
1. Create a folder named bin in your home folder
2. Download http://greker.org/and/python32.tar.gz.
3. Extract the files in the new folder you made. (Aka. so the folder structure is equal to "/home/*yourusername*/bin/py32" and "/home/*yourusername*/bin/python32/").
4. Refresh/Modify your $PATH, or just restart your computer to get the py32 command available.
5. You can now run your project on an ugly hack by doing "py32 my_pyogre_project.py"