vtk加载dicom的时候,CMakeLists.txt需要指定相应的库文件
问题:
Scanning dependencies of target AnimateActors
[ 50%] Building CXX object CMakeFiles/AnimateActors.dir/AnimateActors.cxx.o
[100%] Linking CXX executable AnimateActors
CMakeFiles/AnimateActors.dir/AnimateActors.cxx.o: In function `vtkSmartPointer<vtkDICOMImageReader>::New()':
/opt/VTK9.0.1/include/vtk-9.0/vtkSmartPointer.h:CMakeFiles/AnimateActors.dir/build.make:118: recipe for target 'AnimateActors' failed
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/AnimateActors.dir/all' failed
Makefile:83: recipe for target 'all' failed
218: undefined reference to `vtkDICOMImageReader::New()'
CMakeFiles/AnimateActors.dir/AnimateActors.cxx.o: In function `vtkSmartPointer<vtkImageViewer2>::New()':
/opt/VTK9.0.1/include/vtk-9.0/vtkSmartPointer.h:218: undefined reference to `vtkImageViewer2::New()'
collect2: error: ld returned 1 exit status
make[2]: *** [AnimateActors] Error 1
make[1]: *** [CMakeFiles/AnimateActors.dir/all] Error 2
make: *** [all] Error 2
04:24:09: 进程"/usr/bin/cmake"退出,退出代码 2 。
Error while building/deploying project AnimateActors (kit: 桌面)
When executing step "CMake Build"
通用解决方法
find_package(VTK COMPONENTS REQUIRED)
方法二
find_package(VTK COMPONENTS
vtkCommonColor
vtkCommonCore
vtkCommonDataModel
vtkFiltersSources
vtkInteractionStyle
vtkRenderingContextOpenGL2
vtkRenderingCore
vtkIOExport # vtkDICOMImageReader需要
vtkInteractionImage # vtkImageViewer2需要
vtkRenderingFreeType
vtkRenderingGL2PSOpenGL2
vtkRenderingOpenGL2
QUIET
)