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

David Gobbi david.gobbi at gmail.com
Wed Jan 29 18:11:47 EST 2014


Hi Eric,

I haven't built either vtkLocal or vtkMy with VTK 6, but I have done
experimental builds of some of my own libraries and I can share my
experience.

1) I don't use vtk_module_library or any of the module macros.  Those
macros were written to be used as part of the VTK build, not for
building external modules.  Most of us want to build VTK first, and
then build our own packages separately.  My current understanding is
that people like you and me who build external packages for VTK are
out of luck when it comes to module macros.

2) This means that when I build my own libraries against VTK 6, I do
it much the same way that I did for VTK 5.  In other words, a whole
lotta cmake code.  I have "if()" statements to declare what libraries
I need for VTK 6 versus VTK 5.

3) Recently Bill and Andrew added python scripts that can
automatically identify what modules (and libraries) are required for a
specific collection of source files.  This can help when you need to
find out what VTK 6 libraries you need to link to.  These scripts can
be found in Utilities/Maintenance.

In summary, it isn't easy to build wrapped modules outside of VTK.
VTK 6 makes it super easy to add modules within VTK itself (great for
us core VTK developers) but it doesn't seem to make it any easier to
add modules outside of VTK.

Also, as you noted, vtkLocal and vtkMy seem to be desperately in need
of some TLC.

  David




On Tue, Jan 28, 2014 at 6:10 AM, Eric Nodwell <eric.nodwell at gmail.com> wrote:
> 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