[vtkusers] Custom classes wrapped into Python
Robb Brown
brownr at ucalgary.ca
Thu May 22 11:30:56 EDT 2003
Yes, as I understand it the .so is just a thin wrapper that calls the
.dylib or .a (depending on whether you compiled with static or dynamic
libs). The dylibs work fine with the built in VTK classes and work
well with both my classes and the CISG classes, provided there are a
maximum of two classes in the library. Compiling with static libraries
(one .a plus one .so) allows me to put more than two classes in a
library but doesn't help out with CISG. That two class limit is really
weird, especially since VTK compiles fine and I've made the CMakeLists
files almost identical.
I've seen the problem with gcc not recognizing .so files. There was a
CVS release of VTK a while ago that tried to link all the Python
wrappers to vtkCommonPython which caused the linker to report missing
libraries. Removing vtkCommonPython from the link targets made
everything work fine. I notice that there is now an IF APPLE / ELSE
clause in the CMakeLists to handle this.
I have convinced vtkCISG to build on the mac (without the GUI). We can
play with their classes from C with no problems (I hope) but the Python
wrappers would be nice to have.
I did have to modify most of the files in vtkCISG to work with VTK 4+.
It looks like they develop with VTK 3.2 and a few things have changed
since. The biggest thing was a problem with header files -- I suspect
VTK classes now put as many #includes in the cxx file as opposed to the
.h as possible. A couple updates to the CMake files and you're ready
to build.
On Wednesday, May 21, 2003, at 11:45 AM, Glen Lehmann wrote:
> Hi Robb,
>
> I certainly don't have the answer to your question but here's what I
> know about compiling vtkLocal type directories.
>
> vtk python modules (ie libvtkCommonPython) are ".so" not ".dylib",
> this is because python 2.2 can't recognize .dylibs (python2.3a can
> though, but I haven't tested it). But gcc on os x can't recognize
> .so's, for example:
>
> gcc -L/Users/glehmann/VTK/bin -lvtkCommon -lvtkCommonPython ...
>
> will fild libvtkCommon.dylib but not libvtkCommonPython.so. As far as
> I know there is no way to get gcc to see a .so on os x.
>
> Hopefully, once python2.3 reaches a stable release vtk can compile
> shared libraries as .dylibs so that both python and gcc can recognize
> them.
>
> I'd be interested to hear anything you have to add to this or if you
> have had any success building something like vtkCISG.
>
> Cheers,
> Glen
>
>
> Robb Brown wrote:
>
>>
>> On Mac OSX using a framework build of Python 2.2.2, and VTK 4.2 I
>> have two situations:
>>
>> I have a set of custom classes I wrote in a vtkLocal type directory
>> and the vtkCISG class tree which I'm trying to add Python wrapping >> to.
>>
>> I'm having trouble with VTK's Python wrapping. In my vtkLocal
>> compiled with shared libraries I seem to have a maximum of two
>> classes per module. Any more than this and Python will hang (no
>> message) when importing. Two or less and everything works fine. If
>> I switch to static libraries, the problem seems to go away.
>>
>> vtkCISG on the other hand, shows the same problem (more than two
>> classes hangs Python) but switching to static libraries does not
>> solve the problem.
>>
>> Does anyone have any suggestions? I'm going to try all this on my
>> Linux machine at home tonight.
>>
>>
>> _____________________________
>> Robb Brown
>> Seaman Family MR Center
>> Calgary, AB
>>
>> _______________________________________________
>> 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://public.kitware.com/mailman/listinfo/vtkusers
>>
>
>
>
_____________________________
Robb Brown
Seaman Family MR Center
Calgary, AB
More information about the vtkusers
mailing list