I am trying to build an external ITK module, but linking the new module to the ITK libraries fails. It appears that CMake added the dependent ITK libraries as ITKCommon.lib and ITKSpatialObjects.lib to the link command, whereas these should have had the ITK version number included, i.e. ITKCommon-4.13.lib and ITKSpatialObjects-4.13.lib.
I am using ITK 4.13, built in Release mode and BUILD_SHARED_LIBS=ON. Windows 10, MSVC 2015, CMake version 3.10.2.
I am using ITK 4.13, built in Release mode and BUILD_SHARED_LIBS=ON.
Is it an issue of mixing dynamic and static linking? If you built ITK with BUILD_SHARED_LIBS=ON, then your module should link against the .dll files, instead of the .lib files.
Now, after a clean build of ITK, something different happened. Both ITK and my external module were build with BUILD_SHARED_LIBS=ON, but my external module was statically linked to ITK. The resulting external module library has no dependencies on any ITK shared libraries, such as ITKCommon-4.13.dll, whereas the internal ITK module libraries do have these dependencies.
FYI: I also built SimpleITK and those libraries DO depend on the ITK shared libraries.
Is your external module’s library big, file size wise? Does it appear as a static or dynamic library (.lib or .lib+.dll)? Have you tried linking a simple application to it and invoking some function, .e.g construct a class from the library? Does that work?
Edit: turn on showing full paths in Dependency Walker, different DLLs might be picked up than what you thought.
I have a feeling that I’m beginning to understand what’s going on here. As my external module is made up of templated code only (just a .hxx file), the DLL is just an empty shell. I expected that the ITK build process would pre-process all templated code, compile all of it, and put it into a shared library, but this is apparently not the case.
So, correct me if I’m wrong, but for compiling the ITK Python package (for example) there is no benefit in building shared libraries, is there? The collection of ITK shared libraries has a size of just 20 MB, whereas the Python ITK libraries are 467 MB in total.