Hi all,
as I early mentioned on title, I’m trouble with the wrapping of custom classes to python. I had search for long time but i didnt found nothing to solve my case.
Below all steps to reproduce the error:
then I’ve copied “wrapping” folder from build/lib/python3/dist-packages/wrapping to venv/lib/python3.12/site-packages/
and copied “libvtkWrappable.so” from build/lib/ to venv/lib
after that
python
Python 3.12.7 (main, Feb 12 2025, 12:16:38) [GCC 13.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import wrapping.vtkWrappable
Errore di segmentazione (core dump creato)
I can’t say what goes wrong and I dont have found a solid guide to build correctly this wrapper.
The main goal is to subclass the vtkLegendScaleActor (in c++) in order to import on a python script beacuse I need to modify the logic on BuildRepresentation method, but for now I’m focusing to get a example build.
Can you help me to solve this? Thanks in advance
Your VTK build is probably subtly incompatible with the wheel VTK. You might have better luck grabbing the relevant wheel SDK bundle (named vtk-wheel-sdk-* on this page) and building projects against it.
Hi Ben, thanks for your reply.
Finally I have build the wrapper and works when imported on a custom venv. Now I’m facing another problem that concerns vtkCommonCore compatibiliy. My lib links to my system’s vtk lib, and I think need to build wrapper linking to venv vtk libs.
The error:
from customodules.renderingAnnotation import LegendScaleActor
ImportError: Initialization failed for renderingAnnotation, not compatible with vtkmodules.vtkCommonCore
This appens when the vtk lib goes installed trough pip, but when I copy the entire vtk lib generated on my system (using the same version 9.4.1) this problem goes away.
In any case i need to use pip’s vtk lib.
Any suggestions?
I think this can be fixed by setting INSTALL_RPATH to something relative to $ORIGIN when you build your project, e.g. $ORIGIN/../vtkmodules. I’m foggy on the details because I haven’t worked with rpath-related settings recently.
Hi all,
I want to share some updates.
After serveral attemps I managed to build the lib with SDK download from here as suggested by Ben.
The SDK appears incomplete because can’t resolve symbols like “vtkObject::GetObjectDescription()”
Python 3.12.7 (main, Feb 12 2025, 12:16:38) [GCC 13.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from mymodules import renderingAnnotation
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: /home/matteo/test/vtk_modules/Custom/venv/lib/python3.12/site-packages/mymodules/librenderingAnnotation.so: undefined symbol: _ZNK9vtkObject20GetObjectDescriptionB5cxx11Ev
The missing symbol seems to be a mangling issue. The symbol provided by the SDK’s libvtkCommonCore.so is:
_ZNK9vtkObject20GetObjectDescriptionEv
But the symbol your build wants is
_ZNK9vtkObject20GetObjectDescriptionB5cxx11Ev
So the build is adding B5cxx11 to the symbol. I’m not familiar with “Bnxxxx” mangling, but you can try adding the following to your CMakeLists.txt, which will match with the C++ std version used by the SDK:
Hi all!
Friday on late I’ve resolved and I promised to myself to reply here today.
But I see only today that David has answer with the same solution that I’ve discovered too.
So thanks for the support and for answering. Probably that isn’t a best practice but for now is the only way that permits me to obtain an external library based on vtk wheel.
In any case if you got a better way to do that i’ll appreciate to know it.
For now thanks to all