[vtk-developers] Compiling the VTK Build examples (vtkMy) with python support

Eric Nodwell eric.nodwell at gmail.com
Tue Jan 28 08:10:07 EST 2014


Hi,

We have a project that resembles the vtkMy example from Examples/Build
.  With VTK 5.x, we were able to build it with python wrapping.  In
6.x, we are encountering some issues, and are only managing the python
wrapping with some ugly hacks.

It seems that even the example distributed with VTK,
Examples/Build/vtkMy, fails to build with python support in 6.x.

Before I get to that, I should note that even the C++ library of vtkMy
example doesn't build without some modification for 6.x.  The fixes
for the C++ library are easy however.  For example:

$ diff source/VTK-6.1.0/Examples/Build/vtkMy/Common/CMakeLists.txt
test3/Build/vtkMy/Common/CMakeLists.txt
14a15
> find_package(VTK COMPONENTS vtkCommonCore)
16c17
< TARGET_LINK_LIBRARIES (vtkmyCommon vtkCommon)
---
> target_link_libraries(vtkmyCommon ${VTK_LIBRARIES})

OK, so much for getting the C++ library of the vtkMy example compiling
- easily solved.  But getting the python wrapping working is not so
easily solved.  Here the error:

[  4%] Built target vtkmyCommon
[  9%] Built target vtkmyImaging
[ 13%] Built target vtkmyUnsorted
[ 18%] Built target vtkmyEx1
Linking CXX shared library ../bin/libvtkmyCommonPythonD.dylib
ld: library not found for -lvtkCommon
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [bin/libvtkmyCommonPythonD.dylib] Error 1
make[1]: *** [Common/CMakeFiles/vtkmyCommonPythonD.dir/all] Error 2
make: *** [all] Error 2

The issue is that the CMakeOptions.txt file in vtkMy is trying to link
the python library like this:

  TARGET_LINK_LIBRARIES(vtkmyCommonPythonD vtkmyCommon vtkCommon
vtkCommonPythonD)

In other words, hard-linking to the "vtkCommonPythonD" library, which
no longer exists in VTK 6.x.  Somehow we need to get a list of the vtk
python libraries to link to.  In other words, the python equivalent of
${VTK_LIBRARIES}.  For now we can generate this list by parsing
${VTK_LIBRARIES} and deducing python library names (e.g. from
libvtkCommonCore-6.1.dylib we deduce
libvtkCommonCorePython27D-6.1.dylib), but this is not ideal and
probably not the intended solution.

Has anyone had success in python-wrapping the vtkMy example (built
outside of the VTK source tree)?

As an additional note, my impression is that wrapping generally is
going in the direction employed in the vtkLocal, using the cmake
functions vtk_module and vtk_module_library, which will probably
automatically produce the wrapping (whichever wrapping was used for
VTK itself).  Without complicating this post any further, I will just
note that currently the vtkLocal example does compile outside the VTK
source code tree (with a minor fix), but no python wrapping is
generated.

Thanks for any tips,
Eric


More information about the vtk-developers mailing list