Build error while building the OCCT 7.7.0 with the already installed VTK 9.3.0

I am trying to build the OCCT from source code on my headless Linux machine with the existing VTK package.
I am using the OCCT version 7.7.0 and VTK version 9.3.0
I have built the VTK to support the offscreen/software rendering on Linux headless machine.
I have used below configuration to build the VTK
VTK_RENDERING_BACKEND:STRING=OpenGL2
VTK_USE_X:BOOL=OFF
VTK_OPENGL_HAS_OSMESA:BOOL=ON
I even tried a sample application completely based on VTK to render the sample shape and capture the image of the loaded model and it is working fine.

But when I try to execute the same code through the application where OCCT code is also implemented it is giving the segmentation fault error.
So I tried to build the OCCT with the VTK support and I set the OCCT configuration USE_VTK =true and set the include directories for the both VTK as well as OSMESA.
But while building with the above configuration I am getting below error.

[100%] Building CXX object src/TKIVtkDraw/CMakeFiles/TKIVtkDraw.dir/__/IVtkDraw/IVtkDraw.cxx.o
/home/vikasb/OCCT/source/opencascade-7.7.0/src/IVtkDraw/IVtkDraw.cxx:81:12: fatal error: vtkXRenderWindowInteractor.h: No such file or directory
81 | #include <vtkXRenderWindowInteractor.h>
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [src/TKIVtkDraw/CMakeFiles/TKIVtkDraw.dir/build.make:76: src/TKIVtkDraw/CMakeFiles/TKIVtkDraw.dir/__/IVtkDraw/IVtkDraw.cxx.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:3690: src/TKIVtkDraw/CMakeFiles/TKIVtkDraw.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

So can anyone help to resolve this error and build the OCCT with the existing installed VTK to support the offscreen/software rendering of model on headless Ubuntu ( 20.04) machine.

Thanks

Dmitrii Pasukhin's picture

Hello, We will check your problem with VTK 9.3.0

But as a fast solution, please check version 9.0 of VTK.

Best regards, Dmitrii.

Vikas Beske's picture

Hi Dmitrii,

As you suggested I tried with the VTK 9.0.0 ( download link https://gitlab.kitware.com/vtk/vtk/-/tags/v9.0.0).
VTK build and installation is successful. The sample application to dump a image using VTK only is also running successfully.

But when try to build the OCCT with the VTK getting the same error.
For error please see attached image.

Can you tell me what is wrong here? am I missing some configuration while building?

Dmitrii Pasukhin's picture

I'm not sure, it looks like that VTK was building with specific parameters. I need to check.

Best regards, Dmitrii.

Vikas Beske's picture

Do you need the configurations parameters I am using while building the VTK?
As well as the configuration parameters for OCCT build

regards,
Vikas

Vikas Beske's picture

Hi Dmitrii,

Any update on this?
Any workaround which can be used?

Regards
Vikas

gkv311 n's picture

You have built VTK without Xlib dependency, which TKIVtkDraw library expects.

VTK_USE_X:BOOL=OFF

Either you need patching OCCT to support such configuration (like handling HAVE_XLIB/USE_XLIB=OFF within IVtkDraw) or disable Draw Harness module (BUILD_MODULE_Draw=OFF in CMake).

Vikas Beske's picture

Hi gkv

I am using below parameters while building and installing VTK to support the offscreen rendering

VTK_RENDERING_BACKEND:STRING=OpenGL2
VTK_USE_X:BOOL=OFF
VTK_OPENGL_HAS_OSMESA:BOOL=ON

I guess this configuration is required for headless/offscreen rendering.
If this is not correct can you please suggest a way?

Regards
Vikas