[vtk-developers] Undefined symbols after wrapping my code to Python

David Gobbi david.gobbi at gmail.com
Tue Oct 10 00:27:16 EDT 2017


Seems fishy to me, but in any case, I downloaded your vtkbool package and
was able to build & use it with the following modifications to the
CMakeLists.txt:

1) added vtkWrappingPythonCore to the COMPONENTS:

    find_package(VTK REQUIRED COMPONENTS
        vtkFiltersSources vtkIOLegacy vtkFiltersExtraction
vtkFiltersGeometry vtkFiltersModeling
        vtkRenderingFreeType vtkWrappingPythonCore NO_MODULE)

2) added vtkWrappingPythonCore and vtkCommonExecutionModelPythonD to
target_link_libraries:

    target_link_libraries(${PROJECT_NAME}PythonD ${PROJECT_NAME}
        vtkWrappingPythonCore vtkCommonExecutionModelPythonD)

3) fixed the prefix and suffix for the Python module:

    set_target_properties(${PROJECT_NAME}Python PROPERTIES PREFIX "")
    if(WIN32)
        set_target_properties(${PROJECT_NAME}Python PROPERTIES SUFFIX
".pyd")
    endif()

After that, I built the project and loaded the module into Python:

vtkpython
vtk version 7.1.0
Python 2.7.10 (default, Oct 23 2015, 19:19:21)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from vtkboolPython import vtkPolyDataBooleanFilter
>>> pdbf = vtkPolyDataBooleanFilter()
>>>


In summary, I'm not sure why you were still seeing the missing symbols
after you linked to the library.

 - David


On Mon, Oct 9, 2017 at 9:49 PM, Ronald Römer <rroemer at gmail.com> wrote:

> Yes, that's right.
>
> On 10.10.2017 05:45, David Gobbi wrote:
>
> I'm just trying to make sure that we're communicating the correct
> information back and forth here...
>
> Are you saying that after adding vtkWrappingPythonCore to
> target_link_libraries(), you were able to successfully compile your
> project, but when trying to import the module you saw unresolved symbol
> errors for PyVTKClass_New and other "PyVTK_*" methods?
>
> The vtkWrappingPythonCore library existed in VTK 5, as well, but it was
> called vtkPythonCore back then.
>
>  - David
>
>
> On Mon, Oct 9, 2017 at 9:28 PM, Ronald Römer <rroemer at gmail.com> wrote:
>
>> There are still undefined symbols:
>>
>> 00000000002074e0 d DW.ref.__gxx_personality_v0
>> U PyBool_FromLong
>> U PyDict_SetItemString
>> U PyErr_Occurred
>> U PyInt_FromLong
>> U PyModule_GetDict
>> U PyString_FromString
>> 00000000000040f9 T PyVTKAddFile_vtkPolyDataBooleanFilter
>> U PyVTKClass_New
>> U PyVTKClass_Type
>> U PyVTKClass_vtkPolyDataAlgorithmNew
>> 0000000000004087 T PyVTKClass_vtkPolyDataBooleanFilterNew
>> U PyVTKObject_GetObject
>> U PyVTKObject_SetFlag
>> U PyVTKObject_Type
>> U Py_FatalError
>> U Py_InitModule4_64
>>
>> I think it is a problem with the modularized VTK, that is present since
>> version 6.
>>
>> libvtkWrappingPython27Core-6.3.so exists in the lib directory.
>>
>>
>>
>>
>> On 10.10.2017 05:18, David Gobbi wrote:
>>
>> Did it fail because it didn't find the library?  Or did it fail because
>> it still had unresolved symbols?
>>
>> On Mon, Oct 9, 2017 at 9:14 PM, Ronald Römer <rroemer at gmail.com> wrote:
>>
>>> I already tried this without any success. I have no idea what is wrong
>>> with it. You can try to modify my code to find out the correct necessary
>>> changes.
>>>
>>> Best regards
>>> Ronald
>>>
>>>
>>>
>>> On 10.10.2017 04:59, David Gobbi wrote:
>>>
>>> Hi Ronald,
>>>
>>> Use the following:
>>>
>>> target_link_libraries(${PROJECT_NAME}PythonD ${PROJECT_NAME}
>>> vtkWrappingPythonCore)
>>>
>>> You might also have to add vtkWrappingPythonCore to the components
>>> for find_package(VTK).
>>>
>>>  - David
>>>
>>>
>>> On Mon, Oct 9, 2017 at 8:34 PM, Ronald Römer <rroemer at gmail.com> wrote:
>>>
>>>> Hello,
>>>>
>>>> I'm trying to fix a problem with the python wrapper of my library. In
>>>> my CMakeLists.txt there are the following lines:
>>>>
>>>> find_package(VTK REQUIRED COMPONENTS vtkFiltersSources vtkIOLegacy
>>>> vtkFiltersExtraction vtkFiltersGeometry vtkFiltersModeling
>>>> vtkRenderingFreeType NO_MODULE)
>>>>
>>>> include(${VTK_USE_FILE})
>>>>
>>>> if(VTK_WRAP_PYTHON)
>>>>     find_package(PythonLibs 2.7 REQUIRED)
>>>>
>>>>     if(PYTHONLIBS_FOUND)
>>>>
>>>>         include_directories(${PYTHON_INCLUDE_DIRS}
>>>> ${PROJECT_SOURCE_DIR})
>>>>
>>>>         include(vtkWrapPython)
>>>>
>>>>         vtk_wrap_python3(${PROJECT_NAME}Python
>>>> ${PROJECT_NAME}Python_srcs vtkPolyDataBooleanFilter.cxx)
>>>>
>>>>         add_library(${PROJECT_NAME}PythonD
>>>> ${${PROJECT_NAME}Python_srcs})
>>>>         target_link_libraries(${PROJECT_NAME}PythonD ${PROJECT_NAME})
>>>>
>>>>         add_library(${PROJECT_NAME}Python MODULE
>>>> ${PROJECT_NAME}PythonInit.cxx)
>>>>         target_link_libraries(${PROJECT_NAME}Python
>>>> ${PROJECT_NAME}PythonD)
>>>>
>>>>     endif()
>>>> endif()
>>>>
>>>> When I try to import the module into a python script, I get an import
>>>> error about undefined symbols like PyVTKObject_Type. After a little
>>>> research with nm I found out that the shared object is not linked to
>>>> libvtkWrappingPython27Core. Here are the first lines of it:
>>>>
>>>> U PyBool_FromLong
>>>> U PyDict_SetItemString
>>>> U PyErr_Occurred
>>>> U PyInt_FromLong
>>>> U PyModule_GetDict
>>>> U PyString_FromString
>>>> 0000000000003020 T PyVTKAddFile_vtkPolyDataBooleanFilter
>>>> U PyVTKClass_New
>>>> U PyVTKClass_Type
>>>> U PyVTKClass_vtkPolyDataAlgorithmNew
>>>>
>>>> How to fix this? There is no documentation about the the python
>>>> wrapper, except https://www.vtk.org/Wiki/VTK/Python_Wrapping_FAQ.
>>>>
>>>> I'm actually using VTK 6.3 and my library can be found on
>>>> https://github.com/zippy84/vtkbool.
>>>>
>>>> Best regards
>>>> Ronald
>>>>
>>>
>>>
>>>
>>
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20171009/98b0ffb9/attachment.html>


More information about the vtk-developers mailing list