Building and testing on 64-bit Linux (Gentoo x86_64)

Ionflux

10-11-2007 23:31:58

Hi,

I recently attempted to build python-ogre from source on a Gentoo x84_64 system, actually with at least some success ;), and I thought I would share my experiences.

I decided to stick to the build scripts from svn as much as possible, but I had to edit or repeat certain steps because of problems. I will probably try to repeat it from a clean tree some time.

I first checked out the build scripts from svn, then copied them into the build directory.

General notes:
  1. The scripts continue to run even if there is an error. This caused some confusion in later stages. I think it would be much better if the scripts would abort on an error.[/*:m][/list:u]
    1) 00-PreReqs.sh (skipped)
    1. On my Gentoo system, most of the dependencies were already installed. I only had to install celementtree.[/*:m][/list:u]
      2) 01-RetrieveSource.sh
      1. gccxml checkout failed (cvs: invalid option -- D). This can be fixed by moving the -D option after the 'co' command, which also seems to be the correct syntax according to the man pages.[/*:m][/list:u]
        3) 02-ExtractAndPatch.sh
        There was some trouble with missing downloaded files (for one reason or other), otherwise it worked OK. I manually downloaded the missing files.

        4) 03-BuildTools.sh
        No problems here.

        5) 04-BuildBaseLibs.sh
        1. CEGUI configure failed with:configure: error:

          *** [Gentoo] sanity check failed! ***
          *** libtool.m4 and ltmain.sh have a version mismatch! ***
          *** (libtool.m4 = 1.5.24, ltmain.sh = 1.5.22) ***

          Please run:

          libtoolize --copy --force

          if appropriate, please contact the maintainer of this
          package (or your distribution) for help.

          I tried running the command and retrying, then got this error:/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.2/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -lCEGUIBase
          collect2: ld returned 1 exit status
          make[2]: *** [libCEGUIExpatParser.la] Fehler 1
          make[1]: *** [all-recursive] Fehler 1
          make: *** [all-recursive] Fehler 1

          I ultimately succeeded in building CEGUI using the vanilla sources without the patch and just the configure.[/*:m][/list:u]
          6) 05-BuildAdditionalLibs.sh
          1. Ogreode make failed:OgreOdeBody.cpp: In member function 'OgreOde::Joint* OgreOde::Body::getJoint(int)':
            OgreOdeBody.cpp:523: error: cast from 'dxJoint*' to 'unsigned int' loses precision
            OgreOdeBody.cpp: In destructor 'virtual OgreOde::Body::~Body()':
            OgreOdeBody.cpp:720: error: cast from 'dxBody*' to 'unsigned int' loses precision
            make[2]: *** [OgreOdeBody.lo] Fehler 1
            make[2]: *** Warte auf noch nicht beendete Prozesse...
            g++ -DHAVE_CONFIG_H -I. -I.. -DOGRE_GUI_GLX -DOGRE_CONFIG_LITTLE_ENDIAN -I/mnt/sys01/home/ionflux/src/python-ogre/root/usr/include -I/mnt/sys01/home/ionflux/src/python-ogre/root/usr/include/OGRE -I../include -I/mnt/sys01/home/ionflux/src/python-ogre/root/usr/include -L/mnt/sys01/home/ionflux/src/python-ogre/root/usr/lib -MT OgreOdeCollision.lo -MD -MP -MF .deps/OgreOdeCollision.Tpo -c OgreOdeCollision.cpp -o OgreOdeCollision.o >/dev/null 2>&1
            mv -f .deps/OgreOdeCollision.Tpo .deps/OgreOdeCollision.Plo
            make[2]: Leaving directory `/mnt/sys01/home/ionflux/src/python-ogre/ogreaddons/ogreode/src'
            make[1]: *** [all-recursive] Fehler 1
            make[1]: Leaving directory `/mnt/sys01/home/ionflux/src/python-ogre/ogreaddons/ogreode'
            make: *** [all] Fehler 2

            According to this thread, the problem can be fixed by replacing some casts to 'unsigned int' with casts to 'unsigned long'. Here is a (quick and dirty) patch with all the changes. With this patch, the build works for me.
            There were also some issues when installing the demos. I had to remove '.libs' from the paths in the Makefile.am files of the demo source directories since the binaries were not placed into .libs for some reason.[/*:m][/list:u]
            7) 06-GenerateCode.sh
            1. At first, this script did not work at all because it could not find the pyplusplus module. I fixed it by replacingexport PYTHONPATH=$PREFIX/lib/python$PYTHONVERSION/site-packages with export PYTHONPATH=$PREFIX/lib64/python$PYTHONVERSION/site-packages in the file config.sh (in the directory where the build scripts are placed).[/*:m]
            2. Creating forests code failed because code_generators/forests is missing. I have no idea what to do about it.[/*:m][/list:u]
              8 ) 07-BuildModules.sh
              1. The SCons.Script module was not found. I fixed it by adding$PREFIX/lib64/scons-0.97.0d20070918 to the PYTHONPATH in config.sh.[/*:m]
              2. Building bullet failed:
                /usr/lib/gcc/x86_64-pc-linux-gnu/4.1.2/../../../../x86_64-pc-linux-gnu/bin/ld: /mnt/sys01/home/ionflux/src/python-ogre/root/usr/lib/libLibBulletCollision.a(btAxisSweep3.o): relocation R_X86_64_32S against `vtable for btAxisSweep3' can not be used when making a shared object; recompile with -fPIC
                /mnt/sys01/home/ionflux/src/python-ogre/root/usr/lib/libLibBulletCollision.a: could not read symbols: Bad value

                I fixed this by addingSET(CMAKE_C_FLAGS "-fPIC")
                SET(CMAKE_CXX_FLAGS "-fPIC")
                in CMakeList.txt of bullet and rebuilding bullet.[/*:m]
              3. ogrenewt failed to build because of an incompatible libNewton.a. I do not think there is much to do about it (seeing as how it cannot be built from source anyway) and decide to just skip Newton for now.[/*:m]
              4. Building the ode wrappers causes a swap-of-death when compilingg++ -o build_dir_2.5/ode_0.9/_ode__free_functions.pypp.os -c `pkg-config --cflags OGRE` -I -O2 -I./ -fPIC -I/mnt/sys01/home/ionflux/src/python-ogre/root/usr/include/boost-1_34 -I/mnt/sys01/home/ionflux/src/python-ogre/root/usr/include/ode -I/mnt/sys01/home/ionflux/src/python-ogre/ode-0.9/OPCODE -I/usr/include/python2.5 -I/mnt/sys01/home/ionflux/src/python-ogre/root/usr/include/boost-1_34 generated/ode_0.9/_ode__free_functions.pypp.cpp. This is sometimes caused by too high an optimization setting, but even going back to -O1 did not fix it. So I have to skip ode as well for now.[/*:m][/list:u]
                9) Testing :D
                1. Most of the OGRE examples segfault at first. I fixed this by replacingwindowHnd = self.renderWindow.getCustomAttributeInt("WINDOW") with windowHnd = self.renderWindow.getCustomAttributeUnsignedLong("WINDOW") in ogre/renderer/OGRE/sf_OIS.py[/*:m]
                2. I set PYTHONPATH and LD_LIBRARY_PATH to the appropriate locations in order to run the demos. I also changed the plugin path in plugins.cfg. I seems this should be handled by PythonOgreConfig.py, but it didn't work for me and I just lost my patience and went with updating the environment variables. ;)[/*:m]
                3. Examples which I have tested, with results:
                  1. ogre/Demo_BSP, ogre/Demo_CameraTracking, ogre/Demo_CellShading, ogre/Demo_EnvMap, ogre/Demo_Facial, ogre/Demo_Lighting, ogre/Demo_NodeListener, ogre/Demo_OneFish, ogre/Demo_ParticleFX, ogre/Demo_SkeletonAnimation, ogre/Demo_SkyBox, ogre/Demo_SkyDome, ogre/Demo_SkyPlane, ogre/Demo_Smoke, ogre/Demo_Terrain, ogre/Demo_TextureFX, ogre/Demo_Transparency, cegui/Demo_CEGUI_Gui, cegui/Demo_CEGUI_NewGui, cegui/Demo_CEGUI_Facial, cegui/Demo_CEGUI_DragnDrop: Works fine. :)[/*:m]
                  2. ogre/Demo_Basic: Fails with:python: ../../../OgreMain/include/OgreSingleton.h:66: Ogre::Singleton<T>::Singleton() [with T = Ogre::BspResourceManager]: Assertion `!ms_Singleton' failed.
                    Aborted (core dumped)
                    [/*:m]
                  3. ogre/Demo_Bezier: Works, but with an error on exit:Exception exceptions.AttributeError: "'NoneType' object has no attribute 'Application'" in <bound method BezierApplication.__del__ of <__main__.BezierApplication object at 0x11b4410>> ignored
                    pure virtual method called
                    terminate called without an active exception
                    Aborted (core dumped)
                    [/*:m]
                  4. ogre/Demo_Compositor: Starts up OK after I replace the line windowHnd = self.mMain.getRenderWindow().getCustomAttributeInt("WINDOW") with windowHnd = self.mMain.getRenderWindow().getCustomAttributeUnsignedLong("WINDOW") in CompositorDemo_FrameListener.py.
                    There are several issues with missing namespace prefixes (CEGUI), which I did not have the patience to sort out all of them. I suspect the demo would work fine if these issues were addressed.[/*:m]
                  5. ogre/Demo_Fresnel: Works OK, but segfaults on exit:Exception exceptions.AttributeError: 'rendtargetlistener' in <bound method FresnelApplication.__del__ of <__main__.FresnelApplication object at 0x11f66d0>> ignored
                    Unregistering ResourceManager for type BspLevel
                    Segmentation fault (core dumped)
                    [/*:m]
                  6. ogre/Demo_Grass: Works OK, but the following error occurs on exit:X Error of failed request: BadWindow (invalid Window parameter)
                    Major opcode of failed request: 2 (X_ChangeWindowAttributes)
                    Resource id in failed request: 0x1600002
                    Serial number of failed request: 25
                    Current serial number in output stream: 28
                    [/*:m]
                  7. ogre/Demo_RendererCreate: I am not sure what the demo is supposed to do. I just get a black window.[/*:m]
                  8. ogre/Demo_RenderToTexture: Works OK, but segfaults on exit:Exception exceptions.AttributeError: 'soundManager' in <bound method RenderToTextureApplication.__del__ of <__main__.RenderToTextureApplication object at 0x11ac788>> ignored
                    Unregistering ResourceManager for type BspLevel
                    Segmentation fault (core dumped)
                    [/*:m]
                  9. ogre/Demo_Shadows: Fails withTraceback (most recent call last):
                    File "Demo_Shadows.py", line 1163, in <module>
                    sa.go()
                    File "/home/ionflux/src/python-ogre/root/usr/lib64/python2.5/site-packages/ogre/renderer/OGRE/sf_OIS.py", line 64, in go
                    self.root.startRendering()
                    File "Demo_Shadows.py", line 251, in frameStarted
                    self.Mouse.capture()
                    File "Demo_Shadows.py", line 302, in mouseMoved
                    CEGUI.System.getSingleton().injectMouseWheelChange(e.get_state().Z.rel)
                    File "Demo_Shadows.py", line 407, in handleMouseWheelEvent
                    self.mTranslateVector.z += e.wheelChange * -5.0
                    AttributeError: 'ShadowsListener' object has no attribute 'mTranslateVector'
                    [/*:m]
                  10. ogre/Demo_Shadows_Org: Starts up OK, I also can switch shadow modes, but at some point I got this after pressing 'o':Traceback (most recent call last):
                    File "Demo_Shadows_Org.py", line 557, in <module>
                    application.go()
                    File "/home/ionflux/src/python-ogre/root/usr/lib64/python2.5/site-packages/ogre/renderer/OGRE/sf_OIS.py", line 64, in go
                    self.root.startRendering()
                    File "Demo_Shadows_Org.py", line 348, in frameEnded
                    self.CheckKeyPressed(KC_O, 1, self.changeShadowTechnique)
                    File "Demo_Shadows_Org.py", line 338, in CheckKeyPressed
                    func()
                    File "Demo_Shadows_Org.py", line 316, in changeShadowTechnique
                    shadowTex = shadowTex.getByName(name="ogre/ShadowTexture0") ## returns a None object
                    Boost.Python.ArgumentError: Python argument types in
                    ResourceManager.getByName(TextureManager)
                    did not match C++ signature:
                    getByName(Ogre::ResourceManager {lvalue}, std::string)
                    [/*:m]
                  11. ogre/Demo_SkeletalAnimation: Works OK, but the X error (see above) occurs on exit.[/*:m]
                  12. ogre/Demo_Spinner: Works fine after fixing the window handle issue (see above).[/*:m]
                  13. ogre/Demo_Video: This demo is missing the ogre.video module. I am not sure what needs to be built to get this module.[/*:m]
                  14. ogre/Demo_Water: Fails with exception:Traceback (most recent call last):
                    File "Demo_Water.py", line 622, in <module>
                    application.go()
                    File "/home/ionflux/src/python-ogre/root/usr/lib64/python2.5/site-packages/ogre/renderer/OGRE/sf_OIS.py", line 60, in go
                    if not self._setUp():
                    File "/home/ionflux/src/python-ogre/root/usr/lib64/python2.5/site-packages/ogre/renderer/OGRE/sf_OIS.py", line 101, in _setUp
                    self._createScene()
                    File "Demo_Water.py", line 542, in _createScene
                    self.WaterMesh = WaterMesh.WaterMesh(MESH_NAME, PLANE_SIZE, COMPLEXITY)
                    File "/mnt/sys01/home/ionflux/src/python-ogre/python-ogre/demos/ogre/WaterMesh.py", line 98, in __init__
                    True) ## true?
                    Boost.Python.ArgumentError: Python argument types in
                    HardwareVertexBuffer.writeData(HardwareVertexBuffer, int, int, int, bool)
                    did not match C++ signature:
                    writeData(Ogre::SharedPtr<HardwareVertexBuffer_wrapper> {lvalue}, unsigned long, unsigned long, void const*, bool)
                    writeData(Ogre::HardwareVertexBuffer {lvalue}, unsigned long offset, unsigned long length, void const* pSource, bool discardWholeBuffer=False)
                    (Looks like another 64-bit types issue to me.)[/*:m]
                  15. ogre/Demo_WX: Segfaults:(python:17283): Gdk-WARNING **: gdkdrawable-x11.c:878 drawable is not a pixmap or window
                    GLRenderSystem::createRenderWindow "wxPython render window", 640x480 windowed miscParams: externalWindowHandle=0
                    GLXWindow::create
                    Parsing miscParams
                    Segmentation fault (core dumped)

                    If this is the window handle problem again, I did not find the appropriate line of code.[/*:m][/list:u][/*:m][/list:u]
                    I would have liked to test at least one of the physics frameworks as well but I do not seem to have one that has a completely successful installation. ODE and Newton do not work for reasons explained above, and bullet seems to be missing libLibBulletMath.a (which has not been built - in fact, there seems to be no mention of it anywhere in the build files). :(

                    Remaining problems aside, I am very excited about this project. Especially since it combines the impressive power of Python and OGRE. :) I think I will do some experiments of my own soon. 8)
                    Thanks for the work!

andy

11-11-2007 00:39:57

Thanks very much for this post -- it is great to hear theat fundementally things seem to be working and the list you've give here allows me to go in a make the necessary fixes...

You could try making OgreODE (I too can't get the base ODE to work with Linux, however OgreODE seems OK).. And I'll update Bullet so it works..

Thanks again

Andy

Ionflux

11-11-2007 01:16:45

Hi andy,

I have tried to look into the bullet problem a bit and it seems I got at least something to run. :)

1) In generated/ogrebulletc_1.0/OgreBulletCollisionsRay.hpp I removed the 'inline' prefix from the lines inline const Ogre::Ray &getRay() const;
inline Ogre::Vector3 getRayStartPoint() const;
inline Ogre::Vector3 getRayEndPoint() const;
, since the compiler complained that these inline functions were never defined. I think they have to be defined either in the header file, or they cannot be inline functions. (Not sure about this, but they are defined in OgreBulletCollisionsRay.cpp and removing the inline helps to make it work).

2) I rebuilt bullet using jam (from the system-wide installation). This yields the following libraries:

libbulletcollision.a
libbulletdynamics.a
libbulletmath.a

(This works on 64-bit Linux without any changes to the configuration.)

3) I changed python-ogre/environment.py to link against these libraries, i.e.:class bullet:
version= "2.62"
parent = "ogre/physics"
libs=[Config.LIB_Boost, 'bulletcollision', 'bulletdynamics', 'bulletmath']
andclass ogrebulletc: #
active=True
version = "1.0"
cflags = ""
parent = "ogre/physics"
libs = [Config.LIB_Boost, 'OgreMain',
'bulletcollision', 'bulletdynamics', 'bulletmath'
]


4) I removed sys.exit() in line 120 of Demo_OgreCollision1.py (this really had me puzzled for a short while :P).

Now the demo seems to work! :D It is quite slow with numBoxes = 100, though. With a smaller number of boxes, it speeds up significantly. I do not see any real physics besides the boxes moving in something like parabolic arcs, but well. At least there is something and it does not crash. ;)

[edit]
Okay, now I also built the ogreode wrappers. I wasn't aware that I do not need the ode wrappers as well for this. But anyway, the ogreode wrappers built fine. :)

Here are my testing results:
  1. ogreode/Demo_Scenes: F1, F3, F4, F5 work fine.
    F2 gives me this error:Traceback (most recent call last):
    File "Demo_Scenes.py", line 393, in <module>
    application.go()
    File "/home/ionflux/src/python-ogre/root/usr/lib64/python2.5/site-packages/ogre/renderer/OGRE/sf_OIS.py", line 64, in go
    self.root.startRendering()
    File "Demo_Scenes.py", line 71, in frameEnded
    self._demo.frameEnded(evt, self.Keyboard, self.Mouse)
    File "Demo_Scenes.py", line 263, in frameEnded
    if (self._stepper.step(time)):
    File "/mnt/sys01/home/ionflux/src/python-ogre/python-ogre/demos/ogreode/SimpleScenes.py", line 113, in preStep
    self.addForcesAndTorques()
    File "/mnt/sys01/home/ionflux/src/python-ogre/python-ogre/demos/ogreode/SimpleScenes_Chain.py", line 101, in addForcesAndTorques
    self._first_body.addForce(self._force_to_apply)
    Boost.Python.ArgumentError: Python argument types in
    Body.addForce(Body, int)
    did not match C++ signature:
    addForce(OgreOde::Body {lvalue}, Ogre::Vector3 force)
    F6 does not have any visible effect. :roll:[/*:m]
  2. ogreode/Demo_GranTurism: Works fine (and is a somewhat entertaining demo, too :D)[/*:m][/list:u]I did get the following error once or twice:ODE INTERNAL ERROR 1: assertion "bNormalizationResult" failed in _dNormalize3() [../../include/ode/odemath.h]
    Aborted (core dumped)
    But I guess, since it is called ODE INTERNAL ERROR, it is not your business. ;)

    By the way, the performance seemed very good. I haven't noticed any performance degradation at all before I got bored with adding objects. ;)

    [edit (2)]

    Hunting the 64-bit issues… here's another one: :)
    In python-ogre/generated/ogreal_0.3/OgreALWavSound.cpp:unsigned long frequency = readByte32(buffer32); causes problems. Changing to unsigned int frequency = readByte32(buffer32); solves it, but I think it would be even better to use an exact 32-bit type if the length is required to be 32-bit.

    Also strange is that OGREAL_CHECK(sizeof(mFreq) == sizeof(frequency), 13, "freq and frequency different sizes"); is probably meant to cast an exception with the same text, but the actual exception that gets cast has the message terminate called after throwing an instance of 'Ogre::Exception'
    what(): OGRE EXCEPTION(3:): OpenAL Error: The specified source name is not valid in ~Sound
    . I have no idea why this happens, but it sure is misleading. :roll:

    Also, for whom it may concern: I had problems with OpenAL not picking the right soundcard (of two installed). If this happens, create ~/.openalrc with the entries:# Use ALSA (also valid: sdl, native)
    (define devices '(alsa))
    (define alsa-out-device "hw:1,0")
    (define alsa-in-device "hw:1,0")
    Where hw:x,y refers to the appropriate device.

    Now I can add ogreal/Demo_RenderToTexture to the set of working demos. :)