GeorgeS
(George Stetten)
June 25, 2020, 12:34pm
1
I just upgraded from VTK-8.1.2 to VTK-9.0.0 and am getting a new segmentation fault:
[2A4FCA]vtkRayCastImageDisplayH:20
WARN| Error: no override found for ‘vtkRayCastImageDisplayHelper’.
Segmentation fault: 11
The offending line in my code is
m_smartVolumeMapperSurfaceRendered = vtkSmartPointer::New();
where the smart pointer has been declared in the corresponding .h file
vtkSmartPointer m_smartVolumeMapperSurfaceRendered;
I’m wondering if it is because, to get CMake to Configure and Generate, I had to remove the depreciated line in my CMake file
include(${VTK_USE_FILE})
but have not replaced it with anything.
Otherwise, it seems strange that I suddenly can’t declare a vtkSmartVolumeMapper object after upgrading VTK.
Any help would be appreciated.
ben.boeckel
(Ben Boeckel (Kitware))
June 25, 2020, 1:09pm
2
You’ll need to use the autoinit
macros to do the work that find_package
used to do behind the scenes.
target_link_libraries(mytarget ${any_vis} VTK::ModuleName1 VTK::ModuleName2)
# Add the following line.
vtk_module_autoinit(TARGETS mytarget MODULES VTK::ModuleName1 VTK::ModuleName2)
GeorgeS
(George Stetten)
June 25, 2020, 2:07pm
5
That worked!! Here are the two key lines in my CMake file for my project “bonezone”
target_link_libraries(bonezone ${Glue} ${VTK_LIBRARIES} ${ITK_LIBRARIES} ${OpenCV_LIBS})
vtk_module_autoinit(TARGETS bonezone MODULES ${VTK_LIBRARIES} )
Many thanks.
How about include dirs? ${VTK_INCLUDE_DIRS} is empty and the generated project has no reference to VTK dirs at all when I check in visual studio ???
ben.boeckel
(Ben Boeckel (Kitware))
July 23, 2020, 12:52am
7
Use the targets. They get you everything you need.
dr_ppetrov
(Petar Petrov)
July 24, 2020, 10:18am
8
Thanks, solved it! I also had to put it after linked_targets call in cmake that solved it for me!
nicoco
August 20, 2020, 2:49pm
9
Before VTK 9, I was still able to compile this rather old lib found in the VTK journal .
My knowledge of C++ and CMake being more or less void, is there an easy fix to this CMakeList to make it VTK 9-compilable?
project( vtkMeshGeodesics )
find_package( VTK REQUIRED )
include( ${VTK_USE_FILE} )
set( vtkMeshGeodesics_SRCS
vtkPolyDataGeodesicDistance.cxx
vtkFastMarchingGeodesicDistance.cxx
vtkFastMarchingGeodesicPath.cxx
vtkPolygonalSurfaceContourLineInterpolator2.cxx )
set( vtkMeshGeodesics_HDRS
vtkPolyDataGeodesicDistance.h
vtkFastMarchingGeodesicDistance.h
vtkFastMarchingGeodesicPath.h
vtkPolygonalSurfaceContourLineInterpolator2.h )
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/../FastMarching
${CMAKE_CURRENT_SOURCE_DIR}/../FastMarching/gw_core
${CMAKE_CURRENT_SOURCE_DIR}/../FastMarching/gw_geodesic
)
add_library( vtkMeshGeodesics
${vtkMeshGeodesics_SRCS}
${vtkMeshGeodesics_HDRS} )
target_link_libraries( vtkMeshGeodesics MeshGeodesics )
Removing the VTK_USE_FILE
line removes the CMake warning but compilation terminates with: fatal error: vtkPolyDataAlgorithm.h: file not found
I tried appending
vtk_module_autoinit(
TARGETS vtkMeshGeodesics
MODULES
VTK::WrappingTools
[...]
)
“[…]” being replaced by the list of all VTK modules I could find with a very subtle: grep "Create imported target VTK::" VTK-9.0.1/build/lib/cmake/vtk-9.0/VTK-targets.cmake | cut -c25-
but it did not help.
So… is this easily fixable?
try using include_directories(${VTK_INCLUDE_DIRS})
instead of
include( ${VTK_USE_FILE} )
1 Like
nicoco
August 21, 2020, 7:23am
11
I also had to add target_link_libraries( vtkMeshGeodesics MeshGeodesics ${VTK_LIBRARIES} )
for all the includes to be found! Now it doesn’t compile, but for other reasons. Thanks @Mathilde !