How to include other modules in plugins

文档/每晚/开发人员/教程/创建可加载模块 - 切片器维基 (slicer.org)

I used this tutorial to build extensions, but I still couldn’t successfully compile them。

严重性 代码 说明 项目 文件 禁止显示状态
错误 LNK2019 无法解析的外部符号 __declspec(dllimport) public: static class vtkSlicerVolumesLogic * __cdecl vtkSlicerVolumesLogic::SafeDownCast(class vtkObjectBase *) (_imp?SafeDownCast@vtkSlicerVolumesLogic@@SAPEAV1@PEAVvtkObjectBase@@@Z),函数 public: void __cdecl qSlicertestModuleWidget::Moveimage(void) (?Moveimage@qSlicertestModuleWidget@@QEAAXXZ) 中引用了该符号 qSlicertestModule E:\Slicer_all\testmodule\build\test\qSlicertestModuleWidget.obj 1
cmake_minimum_required(VERSION 3.16.3...3.19.7 FATAL_ERROR)

project(test)

#-----------------------------------------------------------------------------
# Extension meta-information
set(EXTENSION_HOMEPAGE "https://www.slicer.org/wiki/Documentation/Nightly/Extensions/test")
set(EXTENSION_CATEGORY "Examples")
set(EXTENSION_CONTRIBUTORS "John Doe (AnyWare Corp.)")
set(EXTENSION_DESCRIPTION "This is an example of a simple extension")
set(EXTENSION_ICONURL "https://www.example.com/Slicer/Extensions/test.png")
set(EXTENSION_SCREENSHOTURLS "https://www.example.com/Slicer/Extensions/test/Screenshots/1.png")
set(EXTENSION_DEPENDS "NA") # Specified as a list or "NA" if no dependencies

#-----------------------------------------------------------------------------
# Extension dependencies
find_package(Slicer REQUIRED)
include(${Slicer_USE_FILE})

  set(MODULE_INCLUDE_DIRECTORIES
   ${CMAKE_CURRENT_SOURCE_DIR}/Widgets
   ${CMAKE_CURRENT_BINARY_DIR}/Widgets
   ${vtkSlicerVolumesModuleLogic_SOURCE_DIR}
   ${vtkSlicerVolumesModuleLogic_BINARY_DIR}
   )

set(MODULE_TARGET_LIBRARIES
  ${MODULE_TARGET_LIBRARIES}
  vtkSlicerVolumesModuleLogic
)

#-----------------------------------------------------------------------------
# Extension modules
add_subdirectory(test)
## NEXT_MODULE

#-----------------------------------------------------------------------------
include(${Slicer_EXTENSION_GENERATE_CONFIG})
include(${Slicer_EXTENSION_CPACK})

this is my cmakelists

You may have missed adding the volumes logic to the list of target libraries for linking. See this example of Markups module logic linked into the Transforms module logic.