[vtkusers] python wrapping for external function fails on init function

Kate Fissell fissell at pitt.edu
Tue Sep 20 13:41:30 EDT 2016


This worked !!!  Thank you so much for your swift reply David.

On 09/20/2016 11:31 AM, David Gobbi wrote:
> Hi Kate,
>
> The magic CMake incantations for python modules are as follows:
>
>   set(MODULE_PYTHON_NAME vtkhdftIOPython)
>   add_library(${MODULE_PYTHON_NAME} MODULE ${MODULE_PYTHON_NAME}Init.cxx)
>   set_target_properties(${MODULE_PYTHON_NAME} PROPERTIES PREFIX "")
>   if(WIN32 AND NOT CYGWIN)
>     set_target_properties(${MODULE_PYTHON_NAME} PROPERTIES SUFFIX ".pyd")
>   endif()
>   if(CMAKE_VERSION VERSION_GREATER 2.8.8)
>     set_target_properties(${MODULE_PYTHON_NAME} PROPERTIES NO_SONAME 1)
>   endif()
>
> The trick is to set the prefix specifically for vtkhdftIOPython, don't 
> try to set a global prefix with CMAKE_SHARED_LIBRARY_PREFIX.
>
>  - David
>
>
> On Tue, Sep 20, 2016 at 7:43 AM, Kate Fissell <fissell at pitt.edu 
> <mailto:fissell at pitt.edu>> wrote:
>
>     Hi,
>
>     I am running VTK-7.0.0 on an Ubuntu platform using python 2.7.
>     I have a cmake configuration for python wrapping that worked on
>     VTK-6.2.0 and I
>     am trying to port it to VTK-7.
>
>     It builds ok, but when I try to import into python I get the error
>     ImportError: dynamic module does not define init function
>     (initlibvtkhdftIOPython)
>     (my function is vtkhdftIO).
>
>     I believe this is because vtkWrapPythonInit.c no longer has the loop
>     #if defined(__CYGWIN__) || !defined(_WIN32)
>         /* add a "lib" prefix for compatibility with old python scripts */
>         if (strcmp(prefix, "lib") != 0)
>           {
>           prefix = "lib";
>           continue;
>           }
>     #endif
>
>
>     My lib is named libvtkhdftIOPython.so, libvtkhdftIOPythonD.so, but
>     it contains
>     initvtkhdftIOPython  (from running strings on the .so). Under
>     vtk-6.2.0
>     the so file contained
>     initvtkhdftIOPython
>     initlibvtkhdftIOPython
>
>     I have tried various things with CMAKE_SHARED_LIBRARY_PREFIX  to
>     either
>     get cmake to build the initlibvtkhdftIOPython function, or, to
>     take the lib prefix off
>     the .so, but have not succeeded.
>
>     Can you tell me how to get the lib prefix correctly coordinated
>     between init
>     function and lib name  ?
>
>     thanks
>     Kate
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160920/4bc92a1b/attachment.html>


More information about the vtkusers mailing list