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