VTK 加载库报错

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
)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值