I have recently tried installing VTK 9.5 on Ubuntu 24.04 from source (latest .tar.gz release) but when I compile CylinderExample.cxx (from the VTK examples) the window doesn’t show up. I would like my vtk installation to use my Nvidia RTX 3060Ti GPU.
For choosing the compile flag options I used the ninja “gui” generator making sure I allow OpenGL and basically leaving the default options, here is a bref summary of what seems important from the resulting CMakeCache.txt :
BUILD_SHARED_LIBS:BOOL=ON
VTK_DEFAULT_RENDER_WINDOW_OFFSCREEN:BOOL=OFF
VTK_DEFAULT_RENDER_WINDOW_HEADLESS:BOOL=OFF
VTK_GROUP_ENABLE_Imaging:STRING=YES
VTK_GROUP_ENABLE_Qt:STRING=NO
VTK_GROUP_ENABLE_Rendering:STRING=YES
VTK_GROUP_ENABLE_STANDALONE:STRING=YES
VTK_GROUP_ENABLE_StandAlone:STRING=YES
VTK_GROUP_ENABLE_Views:STRING=YES
VTK_INSTALL_SDK:BOOL=ON
VTK_OPENGL_HAS_EGL:BOOL=OFF # didn't remember this one was off i'll retry with ON
VTK_OPENGL_USE_GLES:BOOL=OFF # i think it's for mobile dev
VTK_USE_CUDA:BOOL=OFF # I just want to use the GPU for rendering, nothing more
VTK_USE_X:BOOL=ON # i do have x11 and $DISPLAY -> :1
X11_X11_LIB:FILEPATH=/usr/lib/x86_64-linux-gnu/libX11.so # some similar entries with 'PATH NOT FOUND' but no compile error so I guess it's ok
Additional notes that might be useful :
running xeyes in the shell works.
I am not on Wayland (tried Ubuntu and GNOME desktop)
I tried some fiddling with Xauthority files
After recompiling in Debug, gdb indicates these adresses for renderer, renderWindow : 0x5555555a38a0, 0x5555555a9d80.
strace seems to show that every library he’s trying to use is found. I don’t see any error.
typeid of renderWindow gives : 15vtkRenderWindow.
I tried different build flags, some including VTK, Release mode, OPENGL_HAS_EGL without result.
The python works fine and allows me to render images using my GPU (I can know thanks to nvidia-smi)
When building with cmake, the module-level initialization of VTK’s class factories (for OpenGL etc) is automatic, but since you’re building without cmake, these extra lines of code are needed.
In your original post, you said you were running g++ directly to build your program. That’s why VTK_MODULE_INIT is necessary.
It’s not about how VTK is built, it’s about how programs that use VTK are built.
So in the end it’s not a cmake vs ninja thing, or about anything on the “official setup guidelines” for building VTK. The ccmake -GNinja ../path/to/vtk/source example is still the best way to build VTK.