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

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

    void eval() {}


pybind11::class_<MeshExpr, std::shared_ptr<MeshExpr>, dolfin::Expression>(m, "MeshExpr")

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 "", line 30, in <module>
    module = dolfin.compile_cpp_code(cpp)
  File "/usr/lib/petsc/lib/python3/dist-packages/dolfin/jit/", 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/", line 50, in mpi_jit
    return local_jit(*args, **kwargs)
  File "/usr/lib/petsc/lib/python3/dist-packages/dolfin/jit/", line 106, in dijitso_jit
    return dijitso.jit(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/dijitso/", line 212, in jit
    lib = load_library(signature, cache_params)
  File "/usr/lib/python3/dist-packages/dijitso/", line 363, in load_library
    lib = __import__(signature)
ImportError: /home/colin/.cache/dijitso/lib/ undefined symbol: _ZN31vtkObjectFactoryRegistryCleanupD1Ev

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

Thanks in advance for your help!