Docker - Fenics 2017.1, error when including <dolfin.h> in compiled extension module

Issue #855 new
Umberto Villa created an issue

Hi all,

I was testing the docker image of fenics 2017.1 and I encountered a problem with compiling cpp extension modules using compile_extension_module.

Specifically if the cpp code includes the header <dolfin.h> then compilation will fail when SLEPcEigensolver.h tries to include the slepceps.h header.

Attached you can find the compile.log with the exact error.

To reproduce the error use the modified Probe.h in /home/fenics/demo/undocumented/compiled-extension-module/python/Probe and run demo_compiled-extension-module.py.

All previous versions of Fenics (1.6, 2016.1, 2016.2) used to work well when including <dolfin.h>.

Thanks in advance.

Comments (5)

  1. Jan Blechta
    • changed version to dev
    • marked as minor
    • removed milestone

    The workaround is simple: add os.environ['SLEPC_DIR']+'/include' to include_dirs.

    Extension module facility in DOLFIN is not that robust (it seems especially when using separate includes and sources) and it would be tricky to be able to compile every correct code. I suggest to close this with WONTFIX.

  2. Johannes Ring

    I think the reason that this works in older versions of DOLFIN and not in 2017.1 is that we now call find_package for PETSc and SLEPc in UseDOLFIN.cmake - and we call it without using any of the variables defined by this call. Adding include_directories(${PETSC_INCLUDE_DIRS}) and include_directories(${SLEPC_INCLUDE_DIRS}) in UseDOLFIN.cmake fixes this problem:

    diff --git a/cmake/templates/UseDOLFIN.cmake.in b/cmake/templates/UseDOLFIN.cmake.in
    index 50edd2d34..c85fb9854 100644
    --- a/cmake/templates/UseDOLFIN.cmake.in
    +++ b/cmake/templates/UseDOLFIN.cmake.in
    @@ -49,6 +49,7 @@ if (NOT DOLFIN_USE_FILE_INCLUDED)
           set(DOLFIN_SKIP_BUILD_TESTS TRUE)
           list(APPEND CMAKE_MODULE_PATH "@CMAKE_INSTALL_PREFIX@/@DOLFIN_SHARE_DIR@/cmake")
           find_package(PETSc REQUIRED QUIET)
    +      include_directories(${PETSC_INCLUDE_DIRS})
           endif()
       endif()
    
    @@ -56,6 +57,7 @@ if (NOT DOLFIN_USE_FILE_INCLUDED)
         if (NOT SLEPC::slepc)
           set(DOLFIN_SKIP_BUILD_TESTS TRUE)
           find_package(SLEPc REQUIRED QUIET)
    +      include_directories(${SLEPC_INCLUDE_DIRS})
         endif()
       endif()
    
  3. Umberto Villa reporter

    Thank you very much Johannes for solving this issue!

    I was wondering if this fix could be included in a FEniCS 2017.1.1 (bugfix) release.

    Thanks again!

  4. Johannes Ring

    @uvilla We usually do not make bugfix releases like that and I am not sure if this issue is serious enough to make an exception. You can use Jan's workaround.

  5. Log in to comment