VTK-m: Installing VTK-m as a submodule of VTK

Hello,

On Linux Mint I checked out VTK-Releas branch via GIT and I imported the sub module for VTKm and build it via CMake, ensuring that vtkm and AcceleratorsVTKm are enabled. This is completed successfully. Anyhow, after running “make” and “make install” it does not seem to build the rendering libraries properly.
When I set up a minimal CMake Project and set the VTK_DIR to “/usr/local/lib/cmake/vtk-9.0” and the VTKm_DIR to “/usr/local/lib/cmake/vtk-9.0/vtkm” it doesn’t build with an error message:

/home/david/Documents/minimal/main.cpp:7:10: fatal error: vtkm/rendering/Actor.h: No such file or directory
#include <vtkm/rendering/Actor.h>
         ^~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
CMakeFiles/minimal.dir/build.make:82: recipe for target 'CMakeFiles/minimal.dir/main.cpp.o' failed
make[2]: *** [CMakeFiles/minimal.dir/main.cpp.o] Error 1
CMakeFiles/Makefile2:95: recipe for target 'CMakeFiles/minimal.dir/all' failed
make[1]: *** [CMakeFiles/minimal.dir/all] Error 2
Makefile:103: recipe for target 'all' failed
make: *** [all] Error 2

Since these are all the includes it seems strange that only the Actor.h fails:

#include <vtkm/cont/Initialize.h>
#include <vtkm/filter/Contour.h>
#include <vtkm/io/reader/VTKDataSetReader.h>
#include <vtkm/rendering/Actor.h>

In the src folder pulled via GIT the Actor.h is present, are there any options I’m unaware of for this to be included? Do I have to build VTKm separately and not as a sub module? Building it independently seems to throw other issues at me which I ran into a dead end with, also discussed on here.

Any further information I can provide I’m happy to.

Sincerely,
David

Hi, David,

If your code refers to <vtkm/rendering/Actor.h>, then I’d set VTKm_DIR to /usr/local/lib/cmake/vtk-9.0.

regards,

Paulo

1 Like

Hi Paulo,

When I try to set the directory to /usr/local/lib/cmake/vtk-9.0 and I configure/generate it automatically resets it to /usr/local/lib/cmake/vtk-9.0/vtkm.

Thank you,
David

Then it’s a CMake issue. I guess you have to ask why it resets your settings in its community.

It won’t compile because the preprocessor is expecting this path: /usr/local/lib/cmake/vtk-9.0/vtkm/vtkm/rendering/Actor.h (notice the double vtkm). Maybe you can try creating a symbolic link in /usr/local/lib/cmake/vtk-9.0/vtkm called vtkm that points to /usr/local/lib/cmake/vtk-9.0/vtkm/. Ugly, but it’ll likely work around your issue.

Perhaps you can change CMakeLists.txt of your project to use VTK_DIR instead of VTKm_DIR to find the VTKm headers…

1 Like

I tried that, no luck though.
This is what you meant, right?

david@david-mint:/usr/local/lib/cmake/vtk-9.0/vtkm$ ll
total 36
drwxr-xr-x 3 root root 4096 Jun 30 15:12 ./
drwxr-xr-x 4 root root 4096 Jun 30 11:26 ../
drwxr-xr-x 2 root root 4096 Jun 29 19:34 cmake/
lrwxrwxrwx 1 root root   34 Jun 30 15:12 vtkm -> /usr/local/lib/cmake/vtk-9.0/vtkm/
-rw-r--r-- 1 root root 5844 Jun 29 19:12 VTKmConfig.cmake
-rw-r--r-- 1 root root 1830 Jun 29 19:12 VTKmConfigVersion.cmake
-rw-r--r-- 1 root root 6823 Jun 29 19:22 VTKmTargets.cmake
-rw-r--r-- 1 root root 2161 Jun 30 11:15 VTKmTargets-debug.cmake

Why would only the rendering libs not load? <vtkm/filter/Contour.h> for example works fine.

That path is odd. It doesn’t seem to be a valid include path. I’d expect something like /usr/local/include/vtk-9.0 .

When linking like this:

david@david-mint:/usr/local/lib/cmake/vtk-9.0/vtkm$ ll
total 36
drwxr-xr-x 3 root root 4096 Jun 30 15:35 ./
drwxr-xr-x 4 root root 4096 Jun 30 11:26 ../
drwxr-xr-x 2 root root 4096 Jun 29 19:34 cmake/
lrwxrwxrwx 1 root root   26 Jun 30 15:35 vtkm -> /usr/local/include/vtk-9.0/
-rw-r--r-- 1 root root 5844 Jun 29 19:12 VTKmConfig.cmake
-rw-r--r-- 1 root root 1830 Jun 29 19:12 VTKmConfigVersion.cmake
-rw-r--r-- 1 root root 6823 Jun 29 19:22 VTKmTargets.cmake
-rw-r--r-- 1 root root 2161 Jun 30 11:15 VTKmTargets-debug.cmake

Make fails with a new error: “Too many levels of symbolic links”

/home/david/Documents/minimal/main.cpp:1:10: fatal error: /usr/local/include/vtk-9.0/vtkm/cont/Initialize.h: Too many levels of symbolic links
 #include <vtkm/cont/Initialize.h>
          ^~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
CMakeFiles/minimal.dir/build.make:82: recipe for target 'CMakeFiles/minimal.dir/main.cpp.o' failed
make[2]: *** [CMakeFiles/minimal.dir/main.cpp.o] Error 1
CMakeFiles/Makefile2:95: recipe for target 'CMakeFiles/minimal.dir/all' failed
make[1]: *** [CMakeFiles/minimal.dir/all] Error 2
Makefile:103: recipe for target 'all' failed
make: *** [all] Error 2

Maybe it’s better to remove the symlink. My bad.

Can it be that the rendering libraries are not even build when installing via VTK?

Well, you said you built VTK successfully. Did you do a make install after building?

Yes I did do that. sudo make install -j8

Where is the vtkm/rendering/Actor.h file? Do a find /usr -name "*Actor.h".

This would be the result of that:

david@david-mint:~$ find /usr -name "*Actor.h"
/usr/local/include/vtk-9.0/vtkOpenGLActor.h
/usr/local/include/vtk-9.0/vtkContextActor.h
/usr/local/include/vtk-9.0/vtkParallelCoordinatesActor.h
/usr/local/include/vtk-9.0/vtkBarChartActor.h
/usr/local/include/vtk-9.0/vtkScaledTextActor.h
/usr/local/include/vtk-9.0/vtkQuadricLODActor.h
/usr/local/include/vtk-9.0/vtkXYPlotActor.h
/usr/local/include/vtk-9.0/vtkAxesActor.h
/usr/local/include/vtk-9.0/vtkAxisActor.h
/usr/local/include/vtk-9.0/vtkSpiderPlotActor.h
/usr/local/include/vtk-9.0/vtkLightActor.h
/usr/local/include/vtk-9.0/vtkCubeAxesActor.h
/usr/local/include/vtk-9.0/vtkAnnotatedCubeActor.h
/usr/local/include/vtk-9.0/vtkPolarAxesActor.h
/usr/local/include/vtk-9.0/vtkLODActor.h
/usr/local/include/vtk-9.0/vtkLegendBoxActor.h
/usr/local/include/vtk-9.0/vtkPieChartActor.h
/usr/local/include/vtk-9.0/vtkLegendScaleActor.h
/usr/local/include/vtk-9.0/vtkCameraActor.h
/usr/local/include/vtk-9.0/vtkActor.h
/usr/local/include/vtk-9.0/vtkResliceCursorActor.h
/usr/local/include/vtk-9.0/vtkInteractorStyleTrackballActor.h
/usr/local/include/vtk-9.0/vtkImageActor.h
/usr/local/include/vtk-9.0/vtkTextActor.h
/usr/local/include/vtk-9.0/vtkScalarBarActor.h
/usr/local/include/vtk-9.0/vtkInteractorStyleJoystickActor.h
/usr/local/include/vtk-9.0/vtkOpenGLTextActor.h
/usr/local/include/vtkm-1.5/vtkm/rendering/Actor.h

The last line is from the standalone installation I tried. But the standalone doesn’t work for me because I need certain includes from VTK.

So, how is VTKm install dir configured in the CMake of your program?

To /usr/local/include/vtk-9.0/vtkm

Hence you need to set it to /usr/local/include/vtkm-1.5.

Notice that I asked for the install dir, not where VTKm’s CMakeLists.txt is.

Yes I understood that, thank you for your help up until now. The problem is, when I set up a minimal project which requires both VTK and VTKm the includes work but my program crashes.

Example:

CMake:
VTK_DIR = /usr/local/lib/cmake/vtk-9.0
VTKm_DIR = /usr/local/lib/cmake/vtkm-1.5

main.cpp:

#include <vtkm/cont/Initialize.h>
#include <vtkm/io/reader/VTKDataSetReader.h>
#include <vtkm/filter/Contour.h>
#include <vtkm/rendering/Actor.h>

int main(int argc, char *argv[]) {
    vtkm::cont::Initialize();

    vtkm::io::reader::VTKDataSetReader reader("/home/david/Documents/magField.vtk");
    vtkm::cont::DataSet inData = reader.ReadDataSet();

	vtkm::filter::Contour contour;
    contour.SetActiveField("vec");
	contour.SetIsoValue(-1, 1);
    vtkm::cont::DataSet outData = contour.Execute(inData);

	vtkm::rendering::Actor actor(
    	outData.GetCellSet(),
	    outData.GetCoordinateSystem(),
		outData.GetField("vec")
    );

	return 0;
}

Output is following:

david@david-mint:~/Documents/minimal/bin$ ./minimal 

Loguru caught a signal: SIGSEGV
Segmentation fault (core dumped)

That’s why I tried installing VTKm via VTK by enabling the CMake options to include VTKm. I thought it might help preventing a SEGV, but when I do that, and then therefore build with /usr/local/lib/cmake/vtk-9.0/vtkm instead of /usr/local/lib/cmake/vtkm-1.5 the compiler fails to include actor.h. What I can’t get my head around is why only this functions when I use vtkm::filter::Contour but comment out the actor.

May it be woth Converting the DataSet back to VTK? How hard could it be to convert the result of contour.Execute(inData) to a VTK DataSet instead of VTKm?

Thank you for your time,
David

Please, compile this and run. Does it crash?

#include <vtkm/cont/Initialize.h>
#include <vtkm/io/reader/VTKDataSetReader.h>
#include <vtkm/filter/Contour.h>
#include <vtkm/rendering/Actor.h>

int main(int argc, char *argv[]) {
	return 0;
}