[prev in list] [next in list] [prev in thread] [next in thread]
List: vtk-developers
Subject: Re: [vtk-developers] Undefined symbols after wrapping my code to Python
From: Ronald_Römer <rroemer () gmail ! com>
Date: 2017-10-10 4:45:27
Message-ID: bb1dc966-2b95-5480-5af1-0384a07925bb () gmail ! com
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
It works also for me. Thanks for your help. Could you please change the
documentation so that others don't need to search for a solution.
On 10.10.2017 06:27, David Gobbi wrote:
> 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@gmail.com
> <mailto:rroemer@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@gmail.com
>> <mailto:rroemer@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
>> <http://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@gmail.com <mailto:rroemer@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@gmail.com <mailto:rroemer@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
>>>> <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
>>>> <https://github.com/zippy84/vtkbool>.
>>>>
>>>> Best regards
>>>> Ronald
>>>>
>>>>
>>>
>>>
>>
>>
>
>
[Attachment #5 (text/html)]
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">It works also for me. Thanks for your
help. Could you please change the documentation so that others
don't need to search for a solution.<br>
<br>
<br>
On 10.10.2017 06:27, David Gobbi wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CANwS1=GFmvX=xPm97EnDqJUrvNP-euUoMVCTjSmmXBVWwceFXA@mail.gmail.com">
<div dir="ltr">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:
<div><br>
</div>
<div>1) added vtkWrappingPythonCore to the COMPONENTS:</div>
<div><br>
</div>
<div> find_package(VTK REQUIRED COMPONENTS</div>
<div> vtkFiltersSources vtkIOLegacy vtkFiltersExtraction
vtkFiltersGeometry vtkFiltersModeling</div>
<div> vtkRenderingFreeType vtkWrappingPythonCore
NO_MODULE)</div>
<div><br>
</div>
<div>2) added vtkWrappingPythonCore and
vtkCommonExecutionModelPythonD to target_link_libraries:</div>
<div><br>
</div>
<div> target_link_libraries(${PROJECT_NAME}PythonD
${PROJECT_NAME}</div>
<div> vtkWrappingPythonCore
vtkCommonExecutionModelPythonD)<br>
</div>
<div><br>
</div>
<div>3) fixed the prefix and suffix for the Python module:</div>
<div><br>
</div>
<div> set_target_properties(${PROJECT_NAME}Python PROPERTIES
PREFIX "")<br>
</div>
<div> if(WIN32)</div>
<div> set_target_properties(${PROJECT_NAME}Python
PROPERTIES SUFFIX ".pyd")</div>
<div> endif()</div>
<div><br>
</div>
<div>After that, I built the project and loaded the module into
Python:</div>
<div><br>
</div>
<div>
<div>vtkpython </div>
<div>vtk version 7.1.0</div>
<div>Python 2.7.10 (default, Oct 23 2015, 19:19:21) </div>
<div>[GCC 4.2.1 Compatible Apple LLVM 7.0.0
(clang-700.0.59.5)] on darwin</div>
<div>Type "help", "copyright", "credits" or "license" for more
information.</div>
<div>>>> from vtkboolPython import
vtkPolyDataBooleanFilter</div>
<div>>>> pdbf = vtkPolyDataBooleanFilter()</div>
<div>>>> </div>
</div>
<div><br>
</div>
<div><br>
</div>
<div>In summary, I'm not sure why you were still seeing the
missing symbols after you linked to the library.</div>
<div><br>
</div>
<div> - David</div>
<div><br>
</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Mon, Oct 9, 2017 at 9:49 PM, Ronald
Römer <span dir="ltr"><<a href="mailto:rroemer@gmail.com"
target="_blank" moz-do-not-send="true">rroemer@gmail.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">
<div class="m_6234364206471877386moz-cite-prefix">Yes,
that's right. <br>
<div>
<div class="h5"> <br>
On 10.10.2017 05:45, David Gobbi wrote:<br>
</div>
</div>
</div>
<div>
<div class="h5">
<blockquote type="cite">
<div dir="ltr">I'm just trying to make sure that
we're communicating the correct information back
and forth here...
<div><br>
</div>
<div>Are you saying that after adding <span
style="font-size:12.8px">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?</span></div>
<div><span style="font-size:12.8px"><br>
</span></div>
<div><span style="font-size:12.8px">The
vtkWrappingPythonCore library existed in VTK
5, as well, but it was called vtkPythonCore
back then.</span></div>
<div><span style="font-size:12.8px"><br>
</span></div>
<div><span style="font-size:12.8px"> - David</span></div>
<div><span style="font-size:12.8px"><br>
</span></div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Mon, Oct 9, 2017 at
9:28 PM, Ronald Römer <span dir="ltr"><<a
href="mailto:rroemer@gmail.com"
target="_blank" \
moz-do-not-send="true">rroemer@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0
0 0 .8ex;border-left:1px #ccc
solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">
<div
\
class="m_6234364206471877386m_-1998149975941547339moz-cite-prefix">There are still \
undefined symbols:<br> <br>
00000000002074e0 d
DW.ref.__gxx_personality_v0<span><br>
U PyBool_FromLong<br>
U PyDict_SetItemString<br>
U PyErr_Occurred<br>
U PyInt_FromLong<br>
U PyModule_GetDict<br>
U PyString_FromString<br>
</span> 00000000000040f9 T
PyVTKAddFile_vtkPolyDataBoolea<wbr>nFilter<span><br>
U PyVTKClass_New<br>
U PyVTKClass_Type<br>
U PyVTKClass_vtkPolyDataAlgorith<wbr>mNew<br>
</span> 0000000000004087 T
PyVTKClass_vtkPolyDataBooleanF<wbr>ilterNew<br>
U PyVTKObject_GetObject<br>
U PyVTKObject_SetFlag<br>
U PyVTKObject_Type<br>
U Py_FatalError<br>
U Py_InitModule4_64<br>
<br>
I think it is a problem with the
modularized VTK, that is present since
version 6.<br>
<br>
<a
href="http://libvtkWrappingPython27Core-6.3.so"
target="_blank" \
moz-do-not-send="true">libvtkWrappingPython27Core-6.3<wbr>.so</a> exists in the lib \
directory. <div>
<div class="m_6234364206471877386h5"><br>
<br>
<br>
<br>
On 10.10.2017 05:18, David Gobbi
wrote:<br>
</div>
</div>
</div>
<div>
<div class="m_6234364206471877386h5">
<blockquote type="cite">
<div dir="ltr">Did it fail because it
didn't find the library? Or did it
fail because it still had unresolved
symbols?</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Mon, Oct
9, 2017 at 9:14 PM, Ronald Römer <span
dir="ltr"><<a
href="mailto:rroemer@gmail.com"
target="_blank"
\
moz-do-not-send="true">rroemer@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote"
style="margin:0 0 0
.8ex;border-left:1px #ccc
solid;padding-left:1ex">
<div bgcolor="#FFFFFF"
text="#000000">
<div
class="m_6234364206471877386m_-1998149975941547339m_-3134541148717504743moz-cite-prefix">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.<br>
<br>
Best regards<span
\
class="m_6234364206471877386m_-1998149975941547339HOEnZb"><font color="#888888"><br>
Ronald</font></span>
<div>
<div
\
class="m_6234364206471877386m_-1998149975941547339h5"><br> <br>
<br>
On 10.10.2017 04:59,
David Gobbi wrote:<br>
</div>
</div>
</div>
<div>
<div
\
class="m_6234364206471877386m_-1998149975941547339h5"> <blockquote type="cite">
<div dir="ltr">
<div>Hi Ronald,</div>
<div><br>
</div>
<div>Use the
following:</div>
<div><br>
</div>
\
<div>target_link_libraries(${PROJEC<wbr>T_NAME}PythonD ${PROJECT_NAME}
vtkWrappingPythonCore)</div>
<div><br>
</div>
<div>You might also
have to add
vtkWrappingPythonCore
to the components
for find_package(VTK).</div>
<div><br>
</div>
<div> - David</div>
<div><br>
</div>
<div
class="gmail_extra"><br>
<div
class="gmail_quote">On
Mon, Oct 9, 2017
at 8:34 PM, Ronald
Römer <span
dir="ltr"><<a
href="mailto:rroemer@gmail.com" target="_blank" \
moz-do-not-send="true">rroemer@gmail.com</a>></span> wrote:<br>
<blockquote
class="gmail_quote"
style="margin:0px 0px 0px 0.8ex;border-left:1px solid
\
rgb(204,204,204);padding-left:1ex"> <div dir="ltr">
<div dir="ltr">
<div>
<div>
<div>
<div>
<div>
<div>Hello,<br>
<br>
</div>
I'm trying to
fix a problem
with the
python wrapper
of my library.
In my
CMakeLists.txt
there are the
following
lines:<br>
</div>
<div><br>
</div>
<div>find_package(VTK
REQUIRED
COMPONENTS
vtkFiltersSources
vtkIOLegacy
vtkFiltersExtraction
vtkFiltersGeometry vtkFiltersModeling vtkRenderingFreeType NO_MODULE)<br>
<br>
include(${VTK_USE_FILE})<br>
</div>
<div><br>
if(VTK_WRAP_PYTHON)<br>
find_package(PythonLibs
2.7 REQUIRED)<br>
<br>
if(PYTHONLIBS_FOUND)<br>
<br>
\
include_directories(${PYTHON_I<wbr>NCLUDE_DIRS} ${PROJECT_SOURCE_DIR})<br>
<br>
include(vtkWrapPython)<br>
<br>
\
vtk_wrap_python3(${PROJECT_NAM<wbr>E}Python ${PROJECT_NAME}Python_srcs \
vtkPolyDataBooleanFilter.cxx)<br> <br>
\
add_library(${PROJECT_NAME}Pyt<wbr>honD ${${PROJECT_NAME}Python_srcs})<br>
\
target_link_libraries(${PROJEC<wbr>T_NAME}PythonD ${PROJECT_NAME})<br>
<br>
\
add_library(${PROJECT_NAME}Pyt<wbr>hon MODULE
\
${PROJECT_NAME}PythonInit.cxx)<br>
\
target_link_libraries(${PROJEC<wbr>T_NAME}Python ${PROJECT_NAME}PythonD)<br>
<br>
endif()<br>
endif()<br>
<br>
</div>
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:<br>
<br>
</div>
U
PyBool_FromLong<br>
U
PyDict_SetItemString<br>
U
PyErr_Occurred<br>
U
PyInt_FromLong<br>
U
PyModule_GetDict<br>
U
PyString_FromString<br>
0000000000003020 T PyVTKAddFile_vtkPolyDataBoolea<wbr>nFilter<br>
U
PyVTKClass_New<br>
U
PyVTKClass_Type<br>
U
\
PyVTKClass_vtkPolyDataAlgorith<wbr>mNew<br> <br>
</div>
How to fix
this? There is
no
documentation
about the the
python
wrapper,
except <a
\
href="https://www.vtk.org/Wiki/VTK/Python_Wrapping_FAQ" target="_blank" \
moz-do-not-send="true">https://www.vtk.org/Wiki/VTK/P<wbr>ython_Wrapping_FAQ</a>.<br> \
<br> </div>
I'm actually
using VTK 6.3
and my library
can be found
on <a
\
href="https://github.com/zippy84/vtkbool" target="_blank" \
moz-do-not-send="true">https://github.com/zippy84/vtk<wbr>bool</a>.<br> <br>
</div>
Best regards</div>
<span
class="m_6234364206471877386m_-1998149975941547339m_-3134541148717504743gmail-HOEnZb"><font
color="#888888">
<div>Ronald<br>
</div>
</font></span></div>
</blockquote>
</div>
<br>
</div>
</div>
</blockquote>
<p><br>
</p>
</div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</blockquote>
<p><br>
</p>
</div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</blockquote>
<p><br>
</p>
</div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</blockquote>
<p><br>
</p>
</body>
</html>
_______________________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
Search the list archives at: http://markmail.org/search/?q=vtk-developers
Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/vtk-developers
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic