Wrapping of large C++ libraries

Hi,
I have seen several packages aiming at wrapping C++ code to use in Julia, such as CxxWrap.jl. I haven’t seen a lot of resources about wrapping large pre-existing C++ libraries. I’m thinking about something of the size/complexity of VTK. Could anyone point me to some resources regarding automatic wrapper generation? I think something like VTK would be very interesting to have in a Julia framework.

If your interest was in VTK specifically, one possibility is to lobby Kitware on the VTK discourse.

They do add new interfaces to VTK every once in a while. A long time ago, the only scripting interface for VTK was to Tcl, then Java, JavaScript and C# were added as time went on. Since a lot of people use Julia for all sorts of things, they might be interested in collaborating?

Well, vtk… I dabbled around with it some time ago, see GitHub - j-fu/VTKView.jl: VTK based visualization for Julia . This uses a C wrapper around a C++ API around the VTK API. At that time I was able to build the vtk library only for Linux, maybe another attempt would be worth to undertake. Since than I also looked at vtk.js, see GitHub - j-fu/PlutoVista.jl: Plot library for Pluto notebooks based on plotly.js for 1D data and vtk.js (thus using WebGL) for 2/3D data..

I thinkt that wrapping the VTK C++ API directly to Julia would be a major effort, which probably indeed should be undertaken together with Kitware. Also, Makie is a very serious competitor to VTK (across languages IMHO) which carries around much less legacy and is fully Julian.

I think you can’t expect everything to be automatic in wrapping these huge code base, but it’s certainly doable to a degree that it can be used in Julia, for example, GitHub - Geant4/geant4: Geant4 toolkit for the simulation of the passage of particles through matter - NIM A 506 (2003) 250-303 is a huge code base.

And we have GitHub - JuliaHEP/Geant4.jl (thanks to the amazing work of @peremato )

Thank you for the good inputs!
The Geant4 approach seems interesting - looks like WrapIt can generate a lot of that wrapper code from scratch. I’ll also try to ask around in the VTK discourse, they might be interested in that as well. AFAIK they have some sort of automated way to export their Java, Python, C# bindings through CMake, might be worth to ask.
@j-fu More than visualisation itself, I think having the possibility to open many different file formats and have at least basic manipulation options (interpolation from cell centers to vertices, slicing, clipping, etc.) is the real prize.
Thank you very much for the input!

1 Like

Of course, having a full wrapper would be the optimal solution. But I guess that a combination of
WriteVTK.jl, ReadVTK with PythonCall could provide a quick workaround.