# How to include other modules in plugins

**URL:** <https://discourse.slicer.org/t/how-to-include-other-modules-in-plugins/30035>\
**Category:** Development\
**Tags:** build, extensions\
**Created:** [June 14, 2023, 12:43pm UTC](https://discourse.slicer.org/t/how-to-include-other-modules-in-plugins/30035 "2023-06-14T12:43:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ma1282029525](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ma1282029525/32/66047_2.png) [@ma1282029525](https://discourse.slicer.org/u/ma1282029525)\
**Post date:** [June 14, 2023, 12:43pm UTC](https://discourse.slicer.org/t/how-to-include-other-modules-in-plugins/30035/1 "2023-06-14T12:43:15Z")

</div>

[文档/每晚/开发人员/教程/创建可加载模块 - 切片器维基 (slicer.org)](https://www.slicer.org/wiki/Documentation/Nightly/Developers/Tutorials/CreateLoadableModule)

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 | |

```auto
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

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [June 16, 2023, 2:29pm UTC](https://discourse.slicer.org/t/how-to-include-other-modules-in-plugins/30035/2 "2023-06-16T14:29:20Z")

</div>

You may have missed adding the volumes logic to the list of target libraries for linking. See [this example](https://github.com/Slicer/Slicer/blob/main/Modules/Loadable/Transforms/Logic/CMakeLists.txt#L18) of Markups module logic linked into the Transforms module logic.
