[vtkusers] VTK/Python on AIX 5.3 on Power5

Jens Thomas j.m.h.thomas at dl.ac.uk
Tue Nov 29 14:07:18 EST 2005


Hello

This is partly a question and also partly to document my experiences of
getting VTK to work with Python on AIX, in case others hit similar 
problems,
as I had to put this together form all sorts of sources.

I've built VTK together with the Python bindings on a Power5 system
running AIX 5.3 (which necessitated rebuilding Python with xlC_r as
described below).

VTK works fine if I use the vtkpython binary that is generated during 
the build.

Unfortunately, the vtkpython binary has paths hard-wired into it and I
would like to be able to move my vtk distribution about - as ideally
I'd like to make the whole package available for users of our software
so that they don't have to go through all the trouble I've been
through and can just drop it onto their machine.

To do this on other systems, I package up the .so files from the
VTK/bin directory and the files from Wrapping/Python, and then in the
script I use set the LD_LIBRARY_PATH variables and PYTHONPATH
variables in the script I use to point at these directories.

However, when I try to import vtk using this method I get the following 
message:

 >>> import vtk
./ccp1gui.sh: line 40: 316350 Illegal instruction     (core dumped) 
$guidir/vtk/bin/python2.3

Does anyone have a clue as to why this doesn't happen when using the
vtkpython binary? Are there any other variables I need to set in my
script?

Many thanks,

Jens

Hints on building VTK with Python on AIX

When I first tried to build VTK with the python bindings, the make
worked, although if I fired up python and tried to import vtk, it hit
an illegal instruction and produced a core dump.

It seems this is caused by the python installation being linked with a
C-compiler (xlc_r), which can't initialise C++ objects. I therefore
had to rebuild python using xlC_r. This involved the following steps.

1. Run the configure script. I tried to get the script to use xlC_r by
   default, by setting CC and CXX in the environment:

   export CC=xlC_r
   export CXX=xlC_r
  ./configure --disable-ipv6 --without-gcc --with-cxx=xlC_r  
--with-threads --prefix=/usr/local/packages/vtk

   but for a reason that I don't understand, setting CC and CXX had no
   effect and the configure process defaulted to using cc (which calls
   xlc_r).

2. The build  failed initially as it couldn't find load.h:
   "Python/dynload_aix.c", line 15.10: 1506-296 (S) #include file 
"/usr/lpp/xlC/include/load.h" not found.
   Therefore, I edited Python/dynload_aix.c to change the #include 
"/usr/lpp/xlC/include/load.h" to point to the revelant location

3. The build then contained errors along the lines of:
        sem_trywait: Permission denied
        sem_wait: Permission denied
   This can be fixed by editing pyconfig.h to define 
HAVE_BROKEN_POSIX_SEMAPHORE 1

   Whilst doing this, I also defined AIX_GENUINE_CPLUSPLUS 1 to ensure 
proper C++ support

4. The build then had a raft of errors due to bzlib.h not being found.
   I downloaded a copy of bzlib from  
http://www.bzip.org/1.0.3/bzip2-1.0.3.tar.gz
   I unpacked and copied bzlib.h to the Modules directory and
   edited Modules/bz2module.c to change #include <bzlib.h> to #include 
"bzlib.h"

5. Once you've done the above, run the command: make CC="xlC_r"

6. For some reason setup.py sometimes decides that tk and tcl live in 
/usr/local/lib (even though the /usr/lib directory where they live is 
included in the list of libraries defined within setup.py), so the build 
failed with the message:

        ld: 0706-006 Cannot find or open library file: -l tcl8.3
        ld:open(): A file or directory in the path name does not exist.
         *** WARNING: renaming "_tkinter" since importing it failed: 
from module build/lib.aix-5.3-2.3/_tkinter.so No such file or directory
        can't load library: build/lib.aix-5.3-2.3/_tkinter.so
        error: No such file or directory
        make: 1254-004 The error code from the last command is 1.

   For this reason I had to manually make _tkinter by executing the command:

   ./Modules/ld_so_aix xlC_r -bI:Modules/python.exp 
build/temp.aix-5.3-2.3/_tkinter.o build/temp.aix-5.3-2.3/tkappinit.o 
-L/usr/X11R6/lib /usr/lib/libtk8.3.so /usr/lib/libtcl8.3.so -lX11 -o 
build/lib.aix-5.3-2.3/_tkinter.so

  Rerunning make after this as in 5. then appeared to work fine.

I then built VTK with the attached CMakeCache.txt file

NB: this does not use 64_BIT_IDS (I guess this would be a good idea?)  
and there is no optimisation, although I guess it would make sense use 
-O2 for the production version.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: CMakeCache.txt
Type: text/
Size: 39316 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20051129/c7192567/attachment.bin>


More information about the vtkusers mailing list