[vtkusers] python wrapping local classes

Ed Bachta ebachta at iupui.edu
Thu Aug 28 15:11:35 EDT 2003


Okay, I've got it now. It seems I just had to wipe out an earlier build
of libvtkLocalPython.so that I had built before adding the lines to
include vtkCommonPython in my CMakeLists.txt... I thought cmake would
force a rebuild if a CMakeLists.txt changes. Thanks for the help though,
Leila and Prabhu. :)

- Ed


On Thu, 2003-08-28 at 13:53, Leila Baghdadi wrote:
> Ed how are you compling this, I have a couple of my own classes in 
>                                                                                 
> /../VTK/Examples/Build/vtkLocal
> 
> and I have no problems compiling or linking them.
> 
> I think I just did a ccmake in this directory and built it separately from 
> vtk. Also in top of your CMakeLists.txt you must add which modules and 
> which classes (manually)
> **************************************************************
> CMAKE_MINIMUM_REQUIRED(VERSION 1.6)
> 
> # Set the project/library name here.  Classes should be declared as
> # "class vtkLocal_EXPORT vtkFoo", where vtkLocal is the name of the
> # project set here.
> PROJECT(vtkLocal)
> 
> # Set your list of sources here.  Do not change the name of the
> # vtkLocal_SRCS variable.
> SET(vtkLocal_SRCS
>   vtkLocalExample.cxx
>   vtkImageCanvasSource.cxx
> )
> 
> # List the kits from VTK that are needed by this project.
> SET(vtkLocal_LIBS
>   vtkCommon
>   vtkImaging
> )
> 
> ********************************************
> 
> 
> you can send me your class and I will see if I run to similar problems if 
> I try to compile it.
> 
> HTH
> 
> Leila
> 
> On 28 Aug 2003, Ed Bachta wrote:
> 
> > 
> > Thanks for the suggestion, but that didn't do it...
> > 
> > [ebachta at jackson vtkHistogramColorBar]$ vtkpython
> > vtk version 4.3.0, vtk source $Revision: 1.1610 $, $Date: 2003/06/23
> > 01:45:05 $
> > (GMT)
> > Python 2.2.2 (#1, Feb 24 2003, 19:13:11)
> > [GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-4)] on linux2
> > Type "help", "copyright", "credits" or "license" for more information.
> > >>> from vtkpython import *
> > >>> ren = vtk.vtkRenderer()
> > >>> hcb = vtk.vtkHistogramColorBar()
> > Traceback (most recent call last):
> >   File "<stdin>", line 1, in ?
> > AttributeError: 'module' object has no attribute 'vtkHistogramColorBar'
> > >>> from libvtkLocalPython import *
> > Traceback (most recent call last):
> >   File "<stdin>", line 1, in ?
> > ImportError: /usr/local/src/VTK/bin/libvtkLocalPython.so: undefined
> > symbol: PyVTKClass_vtkActor2DNew
> > >>>
> > 
> > Btw, this is what my Local/CMakeLists.txt looks like (before the "common
> > section" that I pasted in):
> > 
> > SET(KIT Local)
> > SET(UKIT LOCAL)
> > SET(KIT_PYTHON_LIBS vtkCommonPython)
> > SET(KIT_LIBS vtkCommon)
> >                                                                                 
> > SET( Kit_SRCS
> > vtkHistogramColorBar.cxx
> > )
> >                                                                                 
> > SET(Kit_EXTRA_SRCS)
> > SET(Kit_EXTRA_CMDS)
> > SET(Kit_TCL_EXTRA_SRCS)
> > SET(Kit_PYTHON_EXTRA_SRCS)
> > SET(Kit_JAVA_EXTRA_SRCS)
> > 
> > 
> > - Ed
> > 
> > On Thu, 2003-08-28 at 13:30, Leila Baghdadi wrote:
> > > Hi Ed
> > > 
> > > you must try loading
> > > 
> > > from vtkpython import *
> > > from libvtkLocalPython import *
> > > 
> > > 
> > > hope this helps
> > > 
> > > 
> > > Leila
> > > 
> > > On 28 Aug 2003, Ed Bachta wrote:
> > > 
> > > > 
> > > > Hello vtkusers,
> > > > 
> > > > I'm trying to add a class to my VTK build. I was able to add it to a
> > > > directory called Local and build a C++ .so nicely by following the
> > > > suggestions in the VTK README. I can even create a C++ application that
> > > > uses the class. However, I'm having trouble with the python wrapping. I
> > > > seem to get a libvtkLocalPython.so in the bin directory, but when I try
> > > > using my class in a script I have problems. First, it doesn't seem to be
> > > > in the vtk module:
> > > > 
> > > > -----
> > > > [ebachta at jackson Blondin]$ vtkpython
> > > > vtk version 4.3.0, vtk source $Revision: 1.1610 $, $Date: 2003/06/23
> > > > 01:45:05 $
> > > > (GMT)
> > > > Python 2.2.2 (#1, Feb 24 2003, 19:13:11)
> > > > [GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-4)] on linux2
> > > > Type "help", "copyright", "credits" or "license" for more information.
> > > > >>> import vtk
> > > > >>> ren = vtk.vtkRenderer()
> > > > >>> h = vtk.vtkHistogramColorBar()
> > > > Traceback (most recent call last):
> > > >   File "<stdin>", line 1, in ?
> > > > AttributeError: 'module' object has no attribute 'vtkHistogramColorBar'
> > > > -----
> > > > 
> > > > And if I try loading from the python library for Local directly it has
> > > > problems with undefined symbols:
> > > > 
> > > > -----
> > > > >>> from libvtkLocalPython import *
> > > > Traceback (most recent call last):
> > > >   File "<stdin>", line 1, in ?
> > > > ImportError: /usr/local/src/VTK/bin/libvtkLocalPython.so: undefined
> > > > symbol: PyVTKClass_vtkActor2DNew
> > > > -----
> > > > 
> > > > I'm suspecting that I'm missing something in my Local/CMakeLists.txt,
> > > > but I don't know what that would be. I'm working on a Linux box.
> > > > 
> > > > 
> > > 
> > > 
> > 
> > _______________________________________________
> > This is the private VTK discussion list. 
> > Please keep messages on-topic. Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
> > Follow this link to subscribe/unsubscribe:
> > http://www.vtk.org/mailman/listinfo/vtkusers
> > 
> > 
> 
> 




More information about the vtkusers mailing list