Error compiling dolfin cpp code in python

Hello everyone,

I am trying to compile some dolfin cpp code that includes vtk headers in python, as in the example below:

import dolfin

cpp = """
#include <pybind11/pybind11.h>
#include <pybind11/eigen.h>

#include <dolfin/function/Expression.h>
#include <dolfin/mesh/MeshFunction.h>

#include <vtkPolyData.h> // this include seems to produce the error
#include <vtkPointData.h> 

class MeshExpr : public dolfin::Expression
{
public:

    MeshExpr() : dolfin::Expression() {}

    void eval() {}

};

PYBIND11_MODULE(SIGNATURE, m)
{
pybind11::class_<MeshExpr, std::shared_ptr<MeshExpr>, dolfin::Expression>(m, "MeshExpr")
.def(pybind11::init<>());
}
"""

module = dolfin.compile_cpp_code(cpp)

I tried to run this code on ubuntu 20.04 with two different setup:
- using dolfin 2019.1.0 from ubuntu packages and vtk 9.1 built from source
- using conda with dolfin 2019.1.0 and vtk 9.0.1

In both cases I obtain the same error:

Traceback (most recent call last):
  File "test.py", line 30, in <module>
    module = dolfin.compile_cpp_code(cpp)
  File "/usr/lib/petsc/lib/python3/dist-packages/dolfin/jit/pybind11jit.py", line 95, in compile_cpp_code
    module, signature = dijitso_jit(cpp_code, module_name, params,
  File "/usr/lib/petsc/lib/python3/dist-packages/dolfin/jit/jit.py", line 50, in mpi_jit
    return local_jit(*args, **kwargs)
  File "/usr/lib/petsc/lib/python3/dist-packages/dolfin/jit/jit.py", line 106, in dijitso_jit
    return dijitso.jit(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/dijitso/jit.py", line 212, in jit
    lib = load_library(signature, cache_params)
  File "/usr/lib/python3/dist-packages/dijitso/cache.py", line 363, in load_library
    lib = __import__(signature)
ImportError: /home/colin/.cache/dijitso/lib/dolfin_cpp_module_15eebeeafcd4861f4a013c9eef458e55.so: undefined symbol: _ZN31vtkObjectFactoryRegistryCleanupD1Ev

I don’t have this issue on macOS with conda.

Thanks in advance for your help!