Issue building/running Examples

I’m getting back into VTK after a long absence. I just built the C++ libs on Windows and I specified to build the examples when configuring with CMake. It generated the solution, and I built it, but could not find any built examples. I went into the build/Examples folder and loaded up the Examples VS solution file, and it seemed to have all boilerplate targets and didn’t generate any C++ executables when I built that solution. I must be missing something very basic here. Can someone clue me in?

The VTK nightly testing has moved completely to ninja as the build system, so there has been some decay in the VS and even the Makefile generators. The examples might fare better with cmake -G Ninja but YMMV. On the plus side, ninja works very well with the MSVC toolchain, so all you lose is the IDE.

Thanks, David. I’ll give that a try. However:

That doesn’t seem like a minor point to me. Am I missing something?

I looked through the Examples/CMakeLists.txt file and it looks like the examples have just been moved out of the main build. Here are two ways to build them that will work with Visual Studio:

A) build them as part of the testing, specifying either “Release” or “Debug” as the test config.

cd <vtk-build-dir>
ctest -R VTKExample -C Release

B) build them external to VTK

mkdir VTKExamples-build
cd VTKExamples-build
cmake -G <Generator> -DVTK_DIR=<vtk-build-dir> <vtk-source-dir>\Examples

Both of these will create a VTKExamples.sln.

Thanks, David. That actually, worked, and generated a solution in which I could build most of the examples (it skipped a few where it said “project not selected to build for this solution configuration”) Unfortunately, examples that actually render into a vtkRenderWindow with a vtkRenderWindowInteractor never render anything (e.g. “Cube” and “LabeledMesh”). In the debugger, they just step over “renWin->Render();” without incident. The only ones that output graphics are the ones that operate like CreateTree and instantiate a vtkGraphLayoutView and never instantiate a vtkRenderWindow directly. Unfortunately, I know I won’t be able to do what I need to do if I can’t even get a smoke test running with a vtkRenderWindow. Any thoughts?

thanks,
Chris

For some reason, the cube example doesn’t link to either the OpenGL rendering module nor to the interactor style module.

These modules can be added to DataManipulation/Cxx/CMakeLists.txt as follows:

   COMPONENTS
     CommonColor
     FiltersGeometry
-    RenderingCore)
+    RenderingCore
+    InteractionStyle
+    RenderingOpenGL2)

If you make these additions and then re-build the example, it will render.

These modules (InteractionStyle and RenderingOpenGL2) were in this CMakeLists.txt in VTK 8, and I’m really not sure why they were removed from the CMakeLists.txt in VTK 9. They are present in the CMakeLists.txt of some of the other examples, e.g. the Medical examples.

Thanks, David! That worked perfectly.