Page MenuHomePhabricator

MITK does not build on Mac OS 11.6
Closed, WontfixPublic

Description

I'm trying to build MITK on Mac OS 11.6. The build fails while compiling ITK when compiling libITKIOTransformHDF5-4.13.dylib with:

Undefined symbols for architecture x86_64:
  "itk::TransformIOBaseTemplate<double>::SetFileName(char const*)", referenced from:
      vtable for itk::HDF5TransformIOTemplate<double> in itkHDF5TransformIO.cxx.o
  "itk::TransformIOBaseTemplate<double>::SetFileName(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)", referenced from:
      vtable for itk::HDF5TransformIOTemplate<double> in itkHDF5TransformIO.cxx.o
  "itk::TransformIOBaseTemplate<double>::AppendModeOn()", referenced from:
      vtable for itk::HDF5TransformIOTemplate<double> in itkHDF5TransformIO.cxx.o
... many more lines ...
ld: symbol(s) not found for architecture x86_64

The command which is run by make is:

/usr/local/bin/g++-6  -std=c++14  -Wall -Wcast-align -Wdisabled-optimization -Wextra -Wformat=2 -Winvalid-pch -Wno-format-nonliteral -Wpointer-arith -Wshadow -Wunused -Wwrite-strings -funit-at-a-time -Wno-strict-overflow -Wno-deprecated -Wno-invalid-offsetof -Woverloaded-virtual -Wstrict-null-sentinel  -g -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk -dynamiclib -Wl,-headerpad_max_install_names -compatibility_version 1.0.0 -current_version 1.0.0 -o ../../../../lib/libITKIOTransformHDF5-4.13.1.dylib -install_name @rpath/libITKIOTransformHDF5-4.13.1.dylib CMakeFiles/ITKIOTransformHDF5.dir/itkHDF5TransformIO.cxx.o CMakeFiles/ITKIOTransformHDF5.dir/itkHDF5TransformIOFactory.cxx.o   -L/Users/pjensen/MITK-superbuild/ep/lib  -Wl,-rpath,/Users/pjensen/MITK-superbuild/ep/lib -Wl,-rpath,/Users/pjensen/MITK-superbuild/ep/src/ITK-build/lib ../../../../lib/libITKIOTransformBase-4.13.1.dylib /Users/pjensen/MITK-superbuild/ep/lib/libhdf5_cpp_debug.1.8.17.dylib ../../../../lib/libITKTransformFactory-4.13.1.dylib ../../../../lib/libITKTransform-4.13.1.dylib ../../../../lib/libITKCommon-4.13.1.dylib ../../../../lib/libitksys-4.13.1.dylib ../../../../lib/libITKVNLInstantiation-4.13.1.dylib ../../../../lib/libitkvnl_algo-4.13.1.dylib ../../../../lib/libitkvnl-4.13.1.dylib ../../../../lib/libitkv3p_netlib-4.13.1.dylib ../../../../lib/libitknetlib-4.13.1.dylib ../../../../lib/libitkvcl-4.13.1.dylib -lm /Users/pjensen/MITK-superbuild/ep/lib/libhdf5_debug.1.8.17.dylib -lm -ldl

Furthermore, when I check libITKIOTransformBase-4.13.1.dylib, which is being linked by g++, it seems like the symbols that are missing are actually in there:

% nm -UC ../../../../lib/libITKIOTransformBase-4.13.1.dylib | grep "itk::TransformIOBaseTemplate<double>::SetFileName("
0000000000032bc8 t itk::TransformIOBaseTemplate<double>::SetFileName(char const*)
0000000000032c60 t itk::TransformIOBaseTemplate<double>::SetFileName(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)

I'm not sure how to proceed from here. Can you tell what the error might be? Or is this just an ITK bug? I'm happy to provide additional info.

My system is:

  • Mac OS Big Sur 11.5
  • gcc-6 (Homebrew GCC 6.5.0_7) 6.5.0 (although I also had the issue with gcc 8 and gcc 11).
  • cmake version 3.21.3

I am on commit 9b321258b8729346ddae92d204f5325f25523277 and here is a full git diff:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 74ac3443a8..89022296e8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -8,6 +8,9 @@ Please either downgrade to v3.18 or upgrade to at least v3.19.2.\n\
 [1] https://gitlab.kitware.com/cmake/cmake/-/issues/21529")
 endif()
 
+set(CMAKE_C_COMPILER /usr/local/bin/gcc-6)
+set(CMAKE_CXX_COMPILER /usr/local/bin/g++-6)
+
 #-----------------------------------------------------------------------------
 # Policies
 #-----------------------------------------------------------------------------
@@ -252,8 +255,8 @@ endforeach()
 
 option(MITK_USE_BLUEBERRY "Build the BlueBerry platform" ON)
 option(MITK_USE_OpenCL "Use OpenCL GPU-Computing library" OFF)
-option(MITK_USE_OpenMP "Use OpenMP" OFF)
-option(MITK_USE_Python3 "Use Python 3" OFF)
+option(MITK_USE_OpenMP "Use OpenMP" ON)
+option(MITK_USE_Python3 "Use Python 3" ON)
 
 #-----------------------------------------------------------------------------
 # Build configurations

Event Timeline

kislinsk claimed this task.
kislinsk added a subscriber: kislinsk.

Hi and thank you for the comprehensive report. I noticed you use GCC. We support Apple LLVM (Clang) on macOS Mojave, Catalina, and Big Sur. See https://docs.mitk.org/nightly/SupportedPlatformsPage.html for support level details regarding tier 1 and tier 2. Our continuous and nightly build reports can be found here: https://cdash.mitk.org/index.php?project=MITK.

Thank you for such a quick answer. I have now got MITK to build with clang.

The reason I initially used gcc instead was that I had issues with OpenMP. It turns out I needed to install OpenMP support first - specifically, I used brew install libomp.
I know that is not related to MITK as such, but maybe it would be worth it to mention as a hint in the build instructions.

Thank you.