Error when compiling VTK support for opencascad?

When compiling the latest OCC:

commit 8748042259f22d72b3b076bc5433a54ca42734e4 (origin/master, origin/HEAD)
Author: akaftasev <akaftasev@opencascade.com>
Date:   Mon May 22 12:00:32 2023 +0100

against VTK V9.2.6,I got this error:

In file included from /usr/include/GL/glx.h:30,
                 from /home/alex/workspace/OCCT/src/IVtkDraw/IVtkDraw_Interactor.cxx:23:
/usr/local/include/vtk-9.2/vtksys/Status.hxx:15:21: error: expected identifier before ‘int’
   15 | class vtksys_EXPORT Status
      |                     ^~~~~~
In file included from /usr/local/include/vtk-9.2/vtksys/SystemTools.hxx:7,
                 from /usr/local/include/vtk-9.2/vtkSetGet.h:35,
                 from /usr/local/include/vtk-9.2/vtkObject.h:46,
                 from /usr/local/include/vtk-9.2/vtkCommand.h:235,
                 from /usr/local/include/vtk-9.2/vtkRenderWindowInteractor.h:48,
                 from /usr/local/include/vtk-9.2/vtkXRenderWindowInteractor.h:35,
                 from /home/alex/workspace/OCCT/src/IVtkDraw/IVtkDraw_Interactor.cxx:31:
/usr/local/include/vtk-9.2/vtksys/Status.hxx:16:1: error: expected unqualified-id before ‘{’ token
   16 | {
      | ^
make[2]: *** [src/TKIVtkDraw/CMakeFiles/TKIVtkDraw.dir/build.make:104: src/TKIVtkDraw/CMakeFiles/TKIVtkDraw.dir/__/IVtkDraw/IVtkDraw_Interactor.cxx.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:3656: src/TKIVtkDraw/CMakeFiles/TKIVtkDraw.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

It seems that some vtk macros don’t get recognized,and I have tried to add this:

include_directories("/usr/local/include/vtk-9.2")

into
/home/user/OCCT/adm/cmake/vtk.cmake,

but got no luky,Question is:

Can this issue be fixed by modifying vtk.cmake?
If yes,how?

Looks like an opencascade issue.

Maybe,but same OCC code can be compiled with vtk-9.1 successfully.

Hello,

I’m using VTK 9.1 and I found that vtksys_EXPORT is defined in vtksys/Configure.h which is the header used for C. So, please, check whether your final vtksys/Configure.hxx #includes vtksys/Configure.h. If not, VTK’s CMake scripts are likely not generating the former correctly from Utilities/KWSys/vtksysConfigure.hxx.in in VTK source directory, which, in turn, must have these lines:

/* Include C configuration.  */
#include <@KWSYS_NAMESPACE@/Configure.h>

take care,

PC

The core error is that Status is #define’d by X11 headers. The “proper” fix is to reorder the includes so that VTK headers come before X11 headers. Newer VTK has checks that detect and error in this case.