[SOLVED] Build RTK as external module for another module

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
)

Hi Gordian,
not sure what is happening.

A guess is that your tests are not actually linking against ITK: what does the ${MultiObjectRegistration-Test_LIBRARIES} variable have? From your main CMakeLists.txt, it looks like it only contains the contents of ${RTK_LIBRARIES}. You can try printing its contents to see if they actually have the ITK libraries.

Have you built ITK with static/dynamic link libraries?

Is your code available somewhere so that we can try to reproduce your issue?

Finally, formatting your message with the tools available in discourse may contribute to its readability :slight_smile:

HTH,
JON HAITZ

Hi Jon,

i checked the variables using message (STATUS ${VARIABLENAME})

for ${MultiObjectRegistration-Test_LIBRARIES} i got.

  • ITKMetaIO
  • ITKCommon
  • itkdouble-conversion
  • ITKIOBMP
  • ITKIOGDCM
  • ITKIOGIPL
  • ITKIOImageBase
  • ITKIOJPEG
  • ITKIOMeta
  • ITKIONIFTI
  • ITKIONRRD
  • ITKIOPNG
  • ITKIOTIFF
  • ITKIOVTK
  • itksys
  • RTK
  • lpsolve55
  • rtkcudaITKCudaCommon
  • C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v8.0/lib/x64/cuda.lib
  • C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v8.0/lib/x64/cudart.lib
  • C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v8.0/lib/x64/cufft.lib
  • C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v8.0/lib/x64/cublas.lib
  • C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v8.0/lib/x64/cublas_device.lib

for ${MultiObjectRegistration_LIBRARIES}

  • RTK
  • lpsolve55
  • rtkcuda
  • ITKCudaCommon
  • C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v8.0/lib/x64/cuda.lib
  • C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v8.0/lib/x64/cudart.lib
  • C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v8.0/lib/x64/cufft.lib
  • C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v8.0/lib/x64/cublas.lib
  • C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v8.0/lib/x64/cublas_device.lib

The ITK and RTK are build as dynamic libraries using VS2015, 64bit.

The code can be seen here: itkMultiObjectRegistration
Its in an intermediate state as i wanted to set up test scenarios first.

I got another warning from CMake as well:

CMake Warning (dev) at C:/TK/ITK-413/msvc2015_64/ITKTargets.cmake:198 (add_library):
   ADD_LIBRARY called with SHARED option but the target platform does not support dynamic linking.  Building a STATIC library instead.  This may lead to problems.
    Call Stack (most recent call first):
      C:/TK/ITK-413/msvc2015_64/ITKConfig.cmake:54 (include)
      C:/TK/src/RTK-130/cmake/UseRTK.cmake:7 (find_package)
      itk-module-init.cmake:2 (include)
      CMakeLists.txt:3 (include)
    This warning is for project developers.  Use -Wno-dev to suppress it.

Thanks for the formating tip, looks way nicer.

I get access denied for https://bitbucket.org/gordiankabelitz/itkmultiobjectregistration/src/itkMultiObjectRegistrationFramework/

Sorry, I missed to uncheck something. Please try again.

I downloaded RTK from here. My first attempt used ITK-master ends with this configure-time error:

CMake Error at C:/Libs/tbb2018_20180411oss/cmake/TBBConfig.cmake:54 (message):
  This Intel TBB package is intended to be used only in the project with MSVC
Call Stack (most recent call first):
  C:/Dev/ITK-2k17/lib/cmake/ITK-5.0/Modules/ITKTBB.cmake:16 (find_package)
  C:/Dev/ITK-git/CMake/ITKModuleAPI.cmake:76 (include)
  C:/Dev/ITK-git/CMake/ITKModuleAPI.cmake:31 (itk_module_load)
  C:/Dev/ITK-git/CMake/ITKModuleAPI.cmake:129 (_itk_module_config_recurse)
  C:/Dev/ITK-2k17/ITKConfig.cmake:77 (itk_module_config)
  C:/Misc/RTK/cmake/UseRTK.cmake:7 (find_package)
  itk-module-init.cmake:2 (include)
  CMakeLists.txt:3 (include)

Trying to use ITK 4.13, RTK git-master version does not build with RTK_USE_CUDA enabled. And with that disabled, I get ordinary compile errors such as c:\misc\itkmultiobjectregistration\include\itkMultiObjectRegistrationFramework.h(133): error C2061: syntax error: identifier 'CudaForwardProjectionImageFilter'

I got rid of the error LNK1107 by changing following line in the CMakeLists.txt

find_package(ITK REQUIRED)
to
find_package(ITK REQUIRED COMPONENTS ITKCommon)

I am not sure if this is the intended way. The linker error 2019 are still there. I have plenty of those error message therefore I assume they have the same cause. Most of them have something with *IOFactoryRegister.

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

Another oddity I dont get is that the HeaderTest1 includes the .hxx files but not the headers (.h).

// This file has been generated by BuildHeaderTest.py
// To regenerate, build the ITKHeaderTests target.
// This is a test to include each header file for Insight.

#include "itkLabelImageToMultipleImageFilter.hxx"
#include "itkMultiObjectRegistrationFramework.hxx"

#include <cstdlib> // needed for EXIT_SUCCESS macro

int main ( int , char* [] )
{
  return EXIT_SUCCESS;
}

What does the HeaderTest1 do? Should it look for the *.h files?

The platform I use is Windows 10 with VS2015 and CMake 3.11.1
ITK4.13 and the RTK v1.3.0 with Cuda 8.0 are the toolkits. I did some (non-itk modules) other projects which compiled and run fine.

The base idea was to create a new module. The new module takes advantage of the itk and rtk algorithms. Two options are possible:

  1. Build the ITK and RTK (v1.3.0) separate from each other and link the RTK as thirdparty lib to the project (The way I am trying to achieve).
  2. Build the RTK (v1.4.0) as external module for ITK (The restructuring are still in progress at RTK) and build the new module as an additional external module. In this scenario I am not sure about how to link to the RTK in the CMakeLists.txt or itk-module.cmake.
    How can I list all available modules with their module (including external modules) names I can put in the itk_module- macro in itk-module.cmake?

Hi @Gordian,

It sounds like a great project :cool:.

To avoid the build issues, try

  1. Build RTK as an ITK module
  2. Start fresh with the ITKModuleTemplate cookiecutter for your MultiObjectRegistration module.
  3. Add RTK to the DEPENDS section of your itk-module.cmake file.This will add the include directories to your module from RTK, and it will link the libraries and tests created in your module to any libraries that RTK provides. That is, don’t try to do this manually with RTK_LIBRARIES or find_package(RTK etc.

More higher level descriptions and more details of this can be found in the How To Create A Module section of the ITK Software Guide. However, please let us know if anything is unclear or if it does not work as expected.

Header tests are automatically generated tests. They create an executable that #include's all the headers from your module. This ensures that all the modules required by your module have been specified as dependencies in itk-module.cmake; your module’s headers will include the headers of the other modules that they use. By listing dependent modules in itk-module.cmake it ultimately ends up adding the -I/path/to/ITK/ModuleName/include/ to the compiler, so it can find the required headers.

@simon.rit

1 Like

For documentation reasons I will provide my steps towards the module.
Platform: Windows 10, 64bit,Visual Studio 2015, CMake 3.11.1, Cuda 8.0
Toolkits: ITK-4.13 (assume the build is done and working, ITK_DIR is set), RTK git-master
→ Everything is done in DEBUG mode<\br>

  1. Download RTK git-master
    git clone https://github.com/SimonRit/RTK.git

  2. Use cmake-gui for configuration
    “Configure”: I used the provided configuration. Build with

    SHARED_LIBS ON
    CUDA_64_BIT_DEVICE_CODE ON
    RTK_USE_CUDA ON.

    “Configure”. “Generate”.
    A RTKTargets.cmake was created in \lib\cmake\ITK-4.13\Modules\Targets
    A RTK.cmake was created in \lib\cmake\ITK-4.13\Modules

  3. Build RTK with VS
    Open RTK solution file with VS. Build ALL_BUILD.

    Build passed with error in ITKData. Aa far as I can see this was because of a missing/slow server connection.

    Build RUN_TESTS. Result:

Summary

------ Build started: Project: RUN_TESTS, Configuration: Debug x64 ------
1> Test project C:/TK/RTK-master
1> Start 1: RTKKWStyleTest
1> 1/99 Test #1: RTKKWStyleTest … Passed 0.13 sec
1> Start 2: rtkFDKTest
1> 2/99 Test #2: rtkFDKTest … Passed 338.58 sec
1> Start 3: rtkFDKCudaTest
1> 3/99 Test #3: rtkFDKCudaTest … Passed 69.56 sec
1> Start 4: rtkFDKProjWeightCompCudaTest
1> 4/99 Test #4: rtkFDKProjWeightCompCudaTest … Passed 1.80 sec
1> Start 5: rtkFBPParallelTest
1> 5/99 Test #5: rtkFBPParallelTest … Passed 39.46 sec
1> Start 6: rtkImportTest
1> 6/99 Test #6: rtkImportTest … Passed 1.46 sec
1> Start 7: rtkImportCudaTest
1> 7/99 Test #7: rtkImportCudaTest … Passed 1.79 sec
1> Start 8: rtkCropFilterCudaTest
1> 8/99 Test #8: rtkCropFilterCudaTest … Passed 1.76 sec
1> Start 9: rtkMotionCompensatedFDKTest
1> 9/99 Test #9: rtkMotionCompensatedFDKTest … Passed 27.86 sec
1> Start 10: rtkDisplacedDetectorTest
1> 10/99 Test #10: rtkDisplacedDetectorTest … Passed 186.30 sec
1> Start 11: rtkDisplacedDetectorCudaTest
1> 11/99 Test #11: rtkDisplacedDetectorCudaTest … Passed 190.75 sec
1> Start 12: rtkDisplacedDetectorCompCudaTest
1> 12/99 Test #12: rtkDisplacedDetectorCompCudaTest … Passed 1.83 sec
1> Start 13: rtkDisplacedDetectorCompOffsetTest
1> 13/99 Test #13: rtkDisplacedDetectorCompOffsetTest … Passed 1.66 sec
1> Start 14: rtkShortScanTest
1> 14/99 Test #14: rtkShortScanTest … Passed 28.53 sec
1> Start 15: rtkShortScanCudaTest
1> 15/99 Test #15: rtkShortScanCudaTest … Passed 29.45 sec
1> Start 16: rtkShortScanCompCudaTest
1> 16/99 Test #16: rtkShortScanCompCudaTest … Passed 1.85 sec
1> Start 17: rtkRampFilterTest
1> 17/99 Test #17: rtkRampFilterTest … Passed 92.89 sec
1> Start 18: rtkRampFilterCudaTest
1> 18/99 Test #18: rtkRampFilterCudaTest … Passed 35.67 sec
1> Start 19: rtkRampFilterTest2
1> 19/99 Test #19: rtkRampFilterTest2 … Passed 1.62 sec
1> Start 20: rtkRampFilterCudaTest2
1> 20/99 Test #20: rtkRampFilterCudaTest2 … Passed 2.14 sec
1> Start 21: rtkRampFilterNoFFTWTest
1> 21/99 Test #21: rtkRampFilterNoFFTWTest … Passed 91.74 sec
1> Start 22: rtkRampFilterNoFFTWCudaTest
1> 22/99 Test #22: rtkRampFilterNoFFTWCudaTest … Passed 35.18 sec
1> Start 23: rtkScatterGlareFilterTest
1> 23/99 Test #23: rtkScatterGlareFilterTest … Passed 9.36 sec
1> Start 24: rtkScatterGlareFilterCudaTest
1> 24/99 Test #24: rtkScatterGlareFilterCudaTest … Passed 5.51 sec
1> Start 25: rtkScatterGlareFilterNoFFTWTest
1> 25/99 Test #25: rtkScatterGlareFilterNoFFTWTest … Passed 9.41 sec
1> Start 26: rtkGainCorrectionTest
1> 26/99 Test #26: rtkGainCorrectionTest … Passed 1.88 sec
1> Start 27: rtkGainCorrectionCudaTest
1> 27/99 Test #27: rtkGainCorrectionCudaTest … Passed 1.87 sec
1> Start 28: rtkForwardProjectionTest
1> 28/99 Test #28: rtkForwardProjectionTest … Passed 19.11 sec
1> Start 29: rtkForwardProjectionCudaTest
1> 29/99 Test #29: rtkForwardProjectionCudaTest … Passed 14.10 sec
1> Start 30: rtkGeometryFileTest
1> 30/99 Test #30: rtkGeometryFileTest … Passed 1.52 sec
1> Start 31: rtkReg23ProjectionGeometryTest
1> 31/99 Test #31: rtkReg23ProjectionGeometryTest … Passed 167.53 sec
1> Start 32: rtkFOVTest
1> 32/99 Test #32: rtkFOVTest … Passed 12.88 sec
1> Start 33: rtkBinningTest
1> 33/99 Test #33: rtkBinningTest … Passed 1.49 sec
1> Start 34: rtkl0GradientNormTest
1> 34/99 Test #34: rtkl0GradientNormTest … Passed 2.14 sec
1> Start 35: rtkMedianTest
1> 35/99 Test #35: rtkMedianTest … Passed 1.45 sec
1> Start 36: rtkWaterPreCorrectionTest
1> 36/99 Test #36: rtkWaterPreCorrectionTest … Passed 1.46 sec
1> Start 37: rtkLUTBasedVarI0RawToAttTest
1> 37/99 Test #37: rtkLUTBasedVarI0RawToAttTest … Passed 1.59 sec
1> Start 38: rtkDecomposeSpectralProjectionsTest
1> 38/99 Test #38: rtkDecomposeSpectralProjectionsTest … Passed 25.38 sec
1> Start 39: rtkSpectralOneStepTest
1> 39/99 Test #39: rtkSpectralOneStepTest …***Timeout 1500.32 sec
1> Start 40: rtkVectorImageConvertersTest
1> 40/99 Test #40: rtkVectorImageConvertersTest … Passed 1.65 sec
1> Start 41: rtkAmsterdamShroudTest
1> 41/99 Test #41: rtkAmsterdamShroudTest … Passed 5.20 sec
1> Start 42: rtkVarianTest
1> 42/99 Test #42: rtkVarianTest … Passed 2.61 sec
1> Start 43: rtkElektaTest
1> 43/99 Test #43: rtkElektaTest … Passed 4.19 sec
1> Start 44: rtkLUTTest
1> 44/99 Test #44: rtkLUTTest … Passed 2.34 sec
1> Start 45: rtkImagXTest
1> 45/99 Test #45: rtkImagXTest … Passed 2.57 sec
1> Start 46: rtkEdfTest
1> 46/99 Test #46: rtkEdfTest … Passed 2.23 sec
1> Start 47: rtkDigisensTest
1> 47/99 Test #47: rtkDigisensTest … Passed 3.33 sec
1> Start 48: rtkXRadTest
1> 48/99 Test #48: rtkXRadTest …***Failed 2.36 sec
1> Start 49: rtkProjectGeometricPhantomTest
1> 49/99 Test #49: rtkProjectGeometricPhantomTest …***Failed 10.75 sec
1> Start 50: rtkDrawGeometricPhantomTest
1> 50/99 Test #50: rtkDrawGeometricPhantomTest …***Failed 10.54 sec
1> Start 51: rtkWeidingerForwardModelTest
1> 51/99 Test #51: rtkWeidingerForwardModelTest …***Failed 18.74 sec
1> Start 52: rtkNewtonUpdateTest
1> 52/99 Test #52: rtkNewtonUpdateTest …***Failed 3.93 sec
1> Start 53: rtkSartTest
1> 53/99 Test #53: rtkSartTest … Passed 100.50 sec
1> Start 54: rtkSartCudaTest
1> 54/99 Test #54: rtkSartCudaTest … Passed 118.86 sec
1> Start 55: rtkOsemTest
1> 55/99 Test #55: rtkOsemTest … Passed 242.08 sec
1> Start 56: rtkOsemCudaTest
1> 56/99 Test #56: rtkOsemCudaTest … Passed 263.55 sec
1> Start 57: rtkFourDSartTest
1> 57/99 Test #57: rtkFourDSartTest … Passed 31.95 sec
1> Start 58: rtkFourDSartCudaTest
1> 58/99 Test #58: rtkFourDSartCudaTest … Passed 46.20 sec
1> Start 59: rtkFourDConjugateGradientTest
1> 59/99 Test #59: rtkFourDConjugateGradientTest … Passed 10.50 sec
1> Start 60: rtkFourDConjugateGradientCudaTest
1> 60/99 Test #60: rtkFourDConjugateGradientCudaTest … Passed 17.74 sec
1> Start 61: rtkWarpFourDToProjectionStackTest
1> 61/99 Test #61: rtkWarpFourDToProjectionStackTest … Passed 13.62 sec
1> Start 62: rtkWarpFourDToProjectionStackCudaTest
1> 62/99 Test #62: rtkWarpFourDToProjectionStackCudaTest … Passed 18.57 sec
1> Start 63: rtkWarpProjectionStackToFourDTest
1> 63/99 Test #63: rtkWarpProjectionStackToFourDTest … Passed 28.62 sec
1> Start 64: rtkWarpProjectionStackToFourDCudaTest
1> 64/99 Test #64: rtkWarpProjectionStackToFourDCudaTest … Passed 35.37 sec
1> Start 65: rtkCylindricalDetectorReconstructionTest
1> 65/99 Test #65: rtkCylindricalDetectorReconstructionTest … Passed 228.07 sec
1> Start 66: rtkCylindricalDetectorReconstructionCudaTest
1> 66/99 Test #66: rtkCylindricalDetectorReconstructionCudaTest … Passed 227.63 sec
1> Start 67: rtkAdjointOperatorsTest
1> 67/99 Test #67: rtkAdjointOperatorsTest … Passed 25.69 sec
1> Start 68: rtkAdjointOperatorsCudaTest
1> 68/99 Test #68: rtkAdjointOperatorsCudaTest … Passed 27.19 sec
1> Start 69: rtkFourDAdjointOperatorsTest
1> 69/99 Test #69: rtkFourDAdjointOperatorsTest …***Failed 11.42 sec
1> Start 70: rtkInterpolateSplatAdjointTest
1> 70/99 Test #70: rtkInterpolateSplatAdjointTest …***Failed 4.25 sec
1> Start 71: rtkLaplacianTest
1> 71/99 Test #71: rtkLaplacianTest …***Failed 1.64 sec
1> Start 72: rtkLaplacianCudaTest
1> 72/99 Test #72: rtkLaplacianCudaTest …***Failed 1.90 sec
1> Start 73: rtkTotalVariationTest
1> 73/99 Test #73: rtkTotalVariationTest … Passed 47.57 sec
1> Start 74: rtkGradientTest
1> 74/99 Test #74: rtkGradientTest … Passed 0.92 sec
1> Start 75: rtkDivergenceTest
1> 75/99 Test #75: rtkDivergenceTest … Passed 2.01 sec
1> Start 76: rtkLagCorrectionTest
1> 76/99 Test #76: rtkLagCorrectionTest … Passed 3.09 sec
1> Start 77: rtkLagCorrectionCudaTest
1> 77/99 Test #77: rtkLagCorrectionCudaTest … Passed 1.95 sec
1> Start 78: rtkConjugateGradientTest
1> 78/99 Test #78: rtkConjugateGradientTest … Passed 15.35 sec
1> Start 79: rtkWarpTest
1> 79/99 Test #79: rtkWarpTest … Passed 4.75 sec
1> Start 80: rtkI0EstimationTest
1> 80/99 Test #80: rtkI0EstimationTest … Passed 1.59 sec
1> Start 81: rtkSelectOneProjPerCycleTest
1> 81/99 Test #81: rtkSelectOneProjPerCycleTest … Passed 1.92 sec
1> Start 82: rtkIterativeFDKCudaTest
1> 82/99 Test #82: rtkIterativeFDKCudaTest … Passed 27.23 sec
1> Start 83: rtkConjugateGradientReconstructionCudaTest
1> 83/99 Test #83: rtkConjugateGradientReconstructionCudaTest … Passed 174.63 sec
1> Start 84: rtkFourDRoosterCudaTest
1> 84/99 Test #84: rtkFourDRoosterCudaTest … Passed 74.70 sec
1> Start 85: rtkADMMWaveletsCudaTest
1> 85/99 Test #85: rtkADMMWaveletsCudaTest … Passed 303.37 sec
1> Start 86: rtkADMMTotalVariationCudaTest
1> 86/99 Test #86: rtkADMMTotalVariationCudaTest …***Failed 121.11 sec
1> Start 87: rtkRegularizedConjugateGradientCudaTest
1> 87/99 Test #87: rtkRegularizedConjugateGradientCudaTest … Passed 90.74 sec
1> Start 88: rtkCudaRaycastAdjointOperatorsCudaTest
1> 88/99 Test #88: rtkCudaRaycastAdjointOperatorsCudaTest … Passed 2.42 sec
1> Start 89: rtkCyclicDeformationCudaTest
1> 89/99 Test #89: rtkCyclicDeformationCudaTest … Passed 2.06 sec
1> Start 90: rtkWaveletsTest
1> 90/99 Test #90: rtkWaveletsTest … Passed 7.51 sec
1> Start 91: rtkArgsInfoManagerTest
1> 91/99 Test #91: rtkArgsInfoManagerTest … Passed 0.48 sec
1> Start 92: rtkGeometryCloneTest
1> 92/99 Test #92: rtkGeometryCloneTest … Passed 15.61 sec
1> Start 93: rtkGeometryFromMatrixTest
1> 93/99 Test #93: rtkGeometryFromMatrixTest … Passed 17.53 sec
1> Start 94: rtkOraTest
1> 94/99 Test #94: rtkOraTest …***Failed 1.53 sec
1> Start 95: rtkBioscanTest
1> 95/99 Test #95: rtkBioscanTest …**Failed 1.50 sec
1> Start 96: rtkappsimulatedgeometrytest
1> 96/99 Test #96: rtkappsimulatedgeometrytest … Passed 1.01 sec
1> Start 97: rtkappprojectshepploganphantomtest
1> 97/99 Test #97: rtkappprojectshepploganphantomtest … Passed 9.92 sec
1> Start 98: rtkappfdkcudatest
1> 98/99 Test #98: rtkappfdkcudatest … Passed 5.02 sec
1> Start 99: rtkappfdkchecktest
1> 99/99 Test #99: rtkappfdkchecktest … Passed 0.75 sec
1>
1> 87% tests passed, 13 tests failed out of 99
1>
1> Label Time Summary:
1> RTK = 5404.37 sec
proc (95 tests)
1>
1> Total Test time (real) = 5421.29 sec
1>
1> The following tests FAILED:
1> 39 - rtkSpectralOneStepTest (Timeout)
1> 48 - rtkXRadTest (Failed)
1> 49 - rtkProjectGeometricPhantomTest (Failed)
1> 50 - rtkDrawGeometricPhantomTest (Failed)
1> 51 - rtkWeidingerForwardModelTest (Failed)
1> 52 - rtkNewtonUpdateTest (Failed)
1> 69 - rtkFourDAdjointOperatorsTest (Failed)
1> 70 - rtkInterpolateSplatAdjointTest (Failed)
1> 71 - rtkLaplacianTest (Failed)
1> 72 - rtkLaplacianCudaTest (Failed)
1> 86 - rtkADMMTotalVariationCudaTest (Failed)
1> 94 - rtkOraTest (Failed)
1> 95 - rtkBioscanTest (Failed)
1> Errors while running CTest
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(133,5): error MSB3073: The command "setlocal
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(133,5): error MSB3073: “C:\Program Files\CMake\bin\ctest.exe”

–force-new-ctest-process -C Debug
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(133,5): error MSB3073: if %errorlevel% neq 0 goto :cmEnd
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(133,5): error MSB3073: :cmEnd
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(133,5): error MSB3073: endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(133,5): error MSB3073: :cmErrorLevel
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(133,5): error MSB3073: exit /b %1
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(133,5): error MSB3073: :cmDone
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(133,5): error MSB3073: if %errorlevel% neq 0 goto :VCEnd
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(133,5): error MSB3073: :VCEnd" exited with code 8.
========== Build: 0 succeeded, 1 failed, 1 up-to-date, 0 skipped ==========

I did not investigate why some tests are failing. Some of them showed segfault messages.

  1. Setup module with ITKModuleTemplate

Follow instructions in ITKModuleTemplate and How To Create A Module.
Questions: Can you add some more information what to fill in the promts? I have no idea about all the namig conventions . Maybe a short description for the difference between project name and module name? I did not write a filter but was asked for a filter name.
Otherwise the module template is helpful!

Go through all files and replace not necessary lines with name for the new module.
==== CMakeLists.txt ====

cmake_minimum_required(VERSION 3.10.2)
project(itkMultiObjectRegistrationFramework)

set(itkMultiObjectRegistrationFramework_LIBRARIES itkMultiObjectRegistrationFramework)

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

No lib is build inside the src folder. Remove the ENABLE_SHARED. The RTK is added at the DEPENDS secion. The itk-module.cmake looks like this:
==== itk-module.cmake (Updated in step 6) ====

# the top-level README is used for describing this module, just
# re-used it for documentation here
get_filename_component(MY_CURRENT_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
file(READ "${MY_CURRENT_DIR}/README.rst" DOCUMENTATION)

# itk_module() defines the module dependencies in itkMultiObjectRegistrationFramework
# itkMultiObjectRegistrationFramework depends on ITKCommon
# The testing module in itkMultiObjectRegistrationFramework depends on ITKTestKernel
# and ITKMetaIO(besides itkMultiObjectRegistrationFramework and ITKCore)
# By convention those modules outside of ITK are not prefixed with
# ITK.

# define the dependencies of the include module and the tests
itk_module(itkMultiObjectRegistrationFramework
  DEPENDS
    ITKCommon
    ITKReview
 	ITKTransform
 	ITKOptimizers
	ITKRegistrationCommon
    RTK
  COMPILE_DEPENDS
    ITKImageSources
  TEST_DEPENDS
    ITKTestKernel
    ITKMetaIO
  DESCRIPTION
    "${DOCUMENTATION}"
  EXCLUDE_FROM_DEFAULT
)

In the test folder the test files are added for the unit tests. No Baseline is provided yet.
==== test/CMakeLists.txt ====

itk_module_test()

set(itkMultiObjectRegistrationFrameworkTests
  itkMultiObjectRegistrationFrameworkTest.cxx
  itkLabelImageToMultipleImageFilterTest.cxx
  )

CreateTestDriver(itkMultiObjectRegistrationFramework "${itkMultiObjectRegistrationFramework-Test_LIBRARIES}" "${itkMultiObjectRegistrationFrameworkTests}")

itk_add_test(NAME itkLabelImageToMultipleImageFilterTest
  COMMAND itkMultiObjectRegistrationFrameworkTestDriver itkLabelImageToMultipleImageFilterTest
)
  
itk_add_test(NAME itkMultiObjectRegistrationFrameworkTest
  COMMAND itkMultiObjectRegistrationFrameworkTestDriver itkMultiObjectRegistrationFrameworkTest
)

.travis.yml, appveyor.yml, CTestConfig.cmake, LICENSE, README.rst, setup.py are not changed.

  1. Configure itkMultiObjectRegistration in cmake-gui
    Setup a build folder.
    “Configure”.
    Following warnings comes up:

CMake Warning (dev) at C:/TK/src/ITK-413/CMake/ITKModuleMacros.cmake:84 (message):
Unknown argument [RTK]
Call Stack (most recent call first):
itk-module.cmake:14 (itk_module)
C:/TK/src/ITK-413/CMake/ITKModuleExternal.cmake:92 (include)
CMakeLists.txt:9 (include)
This warning is for project developers. Use -Wno-dev to suppress it.

CMake Warning (dev) at C:/TK/src/ITK-413/CMake/ITKModuleMacros.cmake:84 (message):
Unknown argument [RTK]
Call Stack (most recent call first):
itk-module.cmake:14 (itk_module)
C:/TK/src/ITK-413/CMake/ITKModuleMacros.cmake:130 (include)
C:/TK/src/ITK-413/CMake/ITKModuleExternal.cmake:101 (itk_module_impl)
CMakeLists.txt:9 (include)
This warning is for project developers. Use -Wno-dev to suppress it.

CMake Warning (dev) at C:/TK/src/ITK-413/CMake/ITKModuleMacros.cmake:84 (message):
Unknown argument [RTK]
Call Stack (most recent call first):
itk-module.cmake:14 (itk_module)
C:/TK/src/ITK-413/CMake/ITKModuleMacros.cmake:330 (include)
test/CMakeLists.txt:1 (itk_module_test)
This warning is for project developers. Use -Wno-dev to suppress it.

QUESTION: Did I miss something?

It still configures. “Configure”. “Generate”.
A itkMultiObjectRegistrationFramework.cmake is created in \lib\cmake\ITK-4.13\Modules
NO itkMultiObjectRegistrationFrameworkTargets.cmake was created in \lib\cmake\ITK-4.13\Modules\Targets

  1. Build itkMultiObjectRegistrationFramework with VS
    Open solution file. Build ALL_BUILD.
    Build did not pass because of missing modules. I looked up in which module the includes are placed and added this modules to the itk-module.cmake file (s.o.).
    This works like charm.

Build output with remaining errors:

1>------ Build started: Project: itkMultiObjectRegistrationFrameworkHeaderTest1, Configuration: Debug x64 ------
2>------ Build started: Project: itkMultiObjectRegistrationFrameworkTestDriver, Configuration: Debug x64 ------
1>  itkMultiObjectRegistrationFrameworkHeaderTest1.cxx
2>  itkMultiObjectRegistrationFrameworkTest.cxx
1>c:\projekte\multiobjectregistrationframework\include\itkMultiObjectRegistrationFramework.h(31): fatal error C1083: Cannot open include file: 'rtkThreeDCircularProjectionGeometry.h': No such file or directory
2>C:\Projekte\MultiObjectRegistrationFramework\include\itkMultiObjectRegistrationFramework.h(31): fatal error C1083: Cannot open include file: 'rtkThreeDCircularProjectionGeometry.h': No such file or directory
========== Build: 0 succeeded, 2 failed, 2 up-to-date, 0 skipped ==========

QUESTION: The RTK includes are missing. Did I forget to inlcude something?

This is the process I followed. Any help for futher development appreciated, If you need more details I am more than happy to include more informations.

Good idea! Please review these descriptions:

The src directory can be removed, and no library will be generated. However, then this line should be removed from the top level CMakeLists.txt file:

set(itkMultiObjectRegistrationFramework_LIBRARIES itkMultiObjectRegistrationFramework)

This is declaring the libraries provided by your module.

Thanks @Gordian, this is helpful.

It looks good.

We need to address this warning, though:

CMake Warning (dev) at C:/TK/src/ITK-413/CMake/ITKModuleMacros.cmake:84 (message):
Unknown argument [RTK]
Call Stack (most recent call first):
itk-module.cmake:14 (itk_module)
C:/TK/src/ITK-413/CMake/ITKModuleExternal.cmake:92 (include)
CMakeLists.txt:9 (include)

If we address the above warning, it should resolve this.

If you can share the repository, I will try to reproduce and debug the warning.

I set up a new repository: MultiObjectRegistrationFramework.
This repo contains the result from the steps descriped before.

I investigated the warning and the source of it is a early ITK 4.13 version which includes the lines

 elseif("${arg}" MATCHES "^[A-Z][A-Z][A-Z]$")
      set(_doing "")
      message(AUTHOR_WARNING "Unknown argument [${arg}]") 

in ITKModuleMacros.cmake. This responded to the RTK module because it has three letters. :slight_smile:

If you want to build this its necessary to update the ITK version to the current version 4.13.0 or higher.
Therefore I mark this thread as solved until another problem comes up.

Thanks you for your kind suggestions and time.

1 Like