[SOLVED] Build RTK as external module for another module

Gordian
Wed, 06 Jun 2018 10:15:14 +0000
Beginner Questions

Hi,

After figuring out how to create a new module I wanted to create some tests for the module using the testdriver provided by the module template.
I added an external module (RTK) and this works fine.

An error occurs during the build of the tests.
Error LNK1107 invalid or corrupt file: cannot read at 0x3B0 MultiObjectRegistrationTestDriver C:\TK\ITK-413\msvc2015_64\bin\Debug\ITKCommon-4.13.dll

This library wirks fine in other projects. Is the project looking for the ITKCommon-4.13.lib file?

The said file is located there. I couldnt figure out where this error originates from. I looked at the external modules in the github repository without result.
in addition some more errors of the same type show up:
Error LNK2019 unresolved external symbol “__declspec(dllimport) void __cdecl itk::NiftiImageIOFactoryRegister__Private(void)” (_imp?NiftiImageIOFactoryRegister__Private@itk@@YAXXZ) referenced in function “void __cdecl itk::anonymous namespace'::dynamic initializer for ‘ImageIOFactoryRegisterRegisterList’’(void)” (??__EImageIOFactoryRegisterRegisterList@?A0xabc732a1@itk@@YAXXZ) MultiObjectRegistrationHeaderTest1 C:\Projekte\MultiObjectRegistrationBuild\MultiObjectRegistrationHeaderTest1.obj

What is the MultiObjectRegistrationHeaderTest1 supposed to do?
What is the problem with the corrupt DLL file?

Thanks,
Gordian

Below I added the CMakeLists.txt files and the itk-module.cmake file.

======= test\CMakeLists.txt =============

itk_module_test()

set(MultiObjectRegistrationTests
      itkLabelImageToMultipleImageFilterTest.cxx
      itkMultiObjectRegistrationFrameworkTest.cxx
)

CreateTestDriver(MultiObjectRegistration "${MultiObjectRegistration-Test_LIBRARIES}" "${MultiObjectRegistrationTests}")

itk_add_test(NAME itkLabelImageToMultipleImageFilterTest
    COMMAND MultiObjectRegistrationTestDriver itkLabelImageToMultipleImageFilterTest
)

itk_add_test(NAME itkMultiObjectRegistrationFrameworkTest
    COMMAND MultiObjectRegistrationTestDriver itkMultiObjectRegistrationFrameworkTest
)

======= CMakeLists.txt =============

cmake_minimum_required(VERSION 3.8)
if(NOT ITK_SOURCE_DIR)
    include(itk-module-init.cmake)
endif()
project(MultiObjectRegistration)

set(MultiObjectRegistration_LIBRARIES ${RTK_LIBRARIES})

if(NOT ITK_SOURCE_DIR)
  find_package(ITK REQUIRED)
  list(APPEND CMAKE_MODULE_PATH ${ITK_CMAKE_DIR})
  include(ITKModuleExternal)
else()
  itk_module_impl()
endif()

set(MultiObjectRegistration_EXPORT_CODE_INSTALL "
 set(RTK_DIR \"${RTK_DIR}\")
 find_package(RTK REQUIRED)
")
set(MultiObjectRegistration_EXPORT_CODE_BUILD "
if(NOT ITK_BINARY_DIR)
  set(RTK_DIR \"${RTK_DIR}\")
  find_package(RTK REQUIRED)
endif()
")

set(MultiObjectRegistration_SYSTEM_INCLUDE_DIRS ${RTK_INCLUDE_DIRS})
set(MultiObjectRegistration_SYSTEM_LIBRARY_DIRS ${RTK_LIB_DIR})

======= itk-module.cmake =============

get_filename_component(MY_CURRENT_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
file(READ "${MY_CURRENT_DIR}/README.rst" DOCUMENTATION)

#define the dependencies of the include module and the tests
itk_module(MultiObjectRegistration
  DEPENDS
    ITKCommon
    ITKReview
  COMPILE_DEPENDS
    ITKCommon
    ITKIOImageBase
  TEST_DEPENDS
    ITKTestKernel
  DESCRIPTION
    "${DOCUMENTATION}"
  EXCLUDE_FROM_DEFAULT
)

14 posts - 4 participants