I’m trying to build a library which depends upon VTK, but am having trouble getting it to find the header files. I’ve put together a minimal example to show the error:
$ make
Scanning dependencies of target dv-utils-lib
[ 50%] Building CXX object CMakeFiles/dv-utils-lib.dir/src/dvTest.cxx.o
In file included from /Users/davisvigneault/Desktop/src/src/dvTest.cxx:1:
/Users/davisvigneault/Desktop/src/includes/dvTest.h:4:10: fatal error: 'vtkMatrix4x4.h' file not found
#include <vtkMatrix4x4.h>
^~~~~~~~~~~~~~~~
1 error generated.
make[2]: *** [CMakeFiles/dv-utils-lib.dir/src/dvTest.cxx.o] Error 1
make[1]: *** [CMakeFiles/dv-utils-lib.dir/all] Error 2
make: *** [all] Error 2
Thanks for your response. I had previously been using include(${VTK_USE_FILE}), but upon updating to the master branch I began getting an error about there being an incorrect number of arguments to the include function. Is ${VTK_USE_FILE} no longer being set? I gather from Dr. Lorensen’s examples on github [1] that this functionality has somehow been replaced by vtk_module_autoinit in recent versions of VTK.
Ultimately, I was able to get it all working (building a library that depends on VTK, and then building an executable which depends both on VTK and on my library) with something similar to this:
No worries–your response nonetheless pointed me down the right path. At least what the ITK/VTK echosystem occasionally lacks in documentation, it makes up for with an active and supportive community!
Since you are using the VTK Master, try using: Utilities/Maintenance/FindNeededModules.py.
This will produce an output something like this that only lists the modules needed by your library:
find_package(VTK
COMPONENTS
CommonColor
CommonCore
CommonDataModel
CommonTransforms
FiltersGeneral
FiltersModeling
FiltersSources
IOGeometry
IOLegacy
IOPLY
IOXML
RenderingCore
# These modules are suggested since they implement an existing module.
# Uncomment those you need.
# InteractionStyle # implements VTK::RenderingCore
# RenderingFreeType # implements VTK::RenderingCore
# RenderingOpenGL2 # implements VTK::RenderingCore
)
ParaView is in its release cycle and has gotten documentation love. VTK will get the same before the release happens. There’s developer-level documentation, but user-level docs are missing right now.
Hey @amaclean very cool script! I’ve never known the right way to go about figuring out which components are needed.
I tried running it on my project, and it gave me the following:
find_package(VTK
COMPONENTS
CommonCore
CommonDataModel
CommonMath
CommonTransforms
FiltersCore
FiltersExtraction
FiltersGeneral
FiltersModeling
FiltersSources
IOGeometry
IOImage
IOLegacy
ImagingColor
InteractionImage
InteractionWidgets
RenderingAnnotation
RenderingCore
RenderingOpenGL2
RenderingVolumeOpenGL2
# These modules are suggested since they implement an existing module.
# Uncomment those you need.
# InteractionStyle # implements VTK::RenderingCore
# RenderingFreeType # implements VTK::RenderingCore
# RenderingGL2PSOpenGL2 # implements VTK::RenderingOpenGL2
)
Looks good, but now it unfortunately can’t find my Qt headers. I expect that it’s related to the rendering core (see commented at the bottom of the script), but I’ve tried uncommenting each in turn, with no luck. Is there something special I need to do to get this working with Qt?