Slicer build on macOS Monterey

Has anyone built Slicer and Qt 5.15.2 on macOS Monterey with Xcode 13.2. I seem to be running into a lot of issues with building Qt5.15.2 from source (including JCFR’s easy script). I also tried to build Slicer with the Qt binaries but after building the code, I get a lot of errors related to link libraries. One example of the error is shown below:

Error(s):
Cannot load library /S4-new2/S-s/Slicer-build/lib/Slicer-4.13/qt-loadable-modules/libqSlicerDataModule.dylib: (dlopen(/S4-new2/S-s/Slicer-build/lib/Slicer-4.13/qt-loadable-modules/libqSlicerDataModule.dylib, 0x0085): Symbol not found: __ZN6vtksys18SystemToolsManagerC1Ev
Referenced from: /S4-new2/S-s/Slicer-build/lib/Slicer-4.13/qt-loadable-modules/libqSlicerDataModule.dylib
Expected in: /S4-new2/S-s/Slicer-build/lib/Slicer-4.13/qt-loadable-modules/libvtkSlicerDataModuleLogic.dylib)

Any idea how this could be resolved?

Priya

1 Like

I’ve built on Monterey (12.1) with Qt 5.15.2 and Xcode 13.2.1, though not for a couple of weeks. Not sure what those link errors are, sorry, but that configuration should work.

I typically use Qt from homebrew on mac with no problem, but I haven’t built from scratch in a while.

Same for me (Qt from homebrew).

Thanks Steve and Hollister. I am trying to create a Slicer package for a collaborator with a custom module, therefore trying to build Qt from source.

Priya

I just configured with this cmake line:

cmake -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.15 -DCMAKE_BUILD_TYPE:STRING=Debug -DQt5_DIR:PATH=/usr/local/Cellar/qt/5.15.2/lib/cmake/Qt5 ../Slicer

and it’s building now. Should work, I’ll let you know if it doesn’t.

Even if you’re making a custom module, why do you need to build Qt from source?

So this is kinda odd. I now get:

[ 15%] Building CXX object Libs/vtkITK/CMakeFiles/vtkITKPython.dir/vtkITKGradientAnisotropicDiffusionImageFilterPython.cxx.o
In file included from /opt/SB/debug/Slicer-build/Libs/vtkITK/vtkITKGradientAnisotropicDiffusionImageFilterPython.cxx:10:
In file included from /opt/SB/Slicer/Libs/vtkITK/vtkITKGradientAnisotropicDiffusionImageFilter.h:18:
In file included from /opt/SB/Slicer/Libs/vtkITK/vtkITKImageToImageFilterFF.h:21:
In file included from /opt/SB/debug/ITK/Modules/Bridge/VTK/include/itkVTKImageExport.h:143:
In file included from /opt/SB/debug/ITK/Modules/Bridge/VTK/include/itkVTKImageExport.hxx:27:
In file included from /opt/SB/debug/ITK/Modules/Core/Common/include/itkNumericTraitsDiffusionTensor3DPixel.h:22:
In file included from /opt/SB/debug/ITK/Modules/Core/Common/include/itkDiffusionTensor3D.h:26:
In file included from /opt/SB/debug/ITK/Modules/Core/Common/include/itkSymmetricSecondRankTensor.h:29:
/opt/SB/debug/ITK/Modules/Core/Common/include/itkSymmetricEigenAnalysis.h:156:1: warning: control may reach end of non-void function [-Wreturn-type]
}
^
In file included from /opt/SB/debug/Slicer-build/Libs/vtkITK/vtkITKGradientAnisotropicDiffusionImageFilterPython.cxx:10:
In file included from /opt/SB/Slicer/Libs/vtkITK/vtkITKGradientAnisotropicDiffusionImageFilter.h:19:
In file included from /opt/SB/debug/ITK/Modules/Filtering/AnisotropicSmoothing/include/itkGradientAnisotropicDiffusionImageFilter.h:21:
In file included from /opt/SB/debug/ITK/Modules/Filtering/AnisotropicSmoothing/include/itkAnisotropicDiffusionImageFilter.h:21:
In file included from /opt/SB/debug/ITK/Modules/Core/FiniteDifference/include/itkDenseFiniteDifferenceImageFilter.h:21:
In file included from /opt/SB/debug/ITK/Modules/Core/FiniteDifference/include/itkFiniteDifferenceImageFilter.h:21:
In file included from /opt/SB/debug/ITK/Modules/Core/Common/include/itkInPlaceImageFilter.h:189:
/opt/SB/debug/ITK/Modules/Core/Common/include/itkInPlaceImageFilter.hxx:97:5: error: use of undeclared identifier '__ASSERT_FUNCTION'
    itkAssertOrThrowMacro(inputAsOutput.IsNotNull(), "Unable to convert input image to output image as expected!");

Looks like __ASSERT_FUNCTION is from assert.h? Am I misreading this?

Hey @pieper Steve, have you seen this ITK problem on a Mac? (or anybody else)?

I am experiencing the same issues when starting Slicer.

cmake configuration below:


   cmake ../../sources/cpp/Slicer/ \
    -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=12.1 \
    -DQt5_DIR:PATH=/Users/herzc/Qt/5.15.2/clang_64/lib/cmake/Qt5 \
    -DCMAKE_OSX_ARCHITECTURES:STRING=x86_64 \
    -DSlicer_USE_SYSTEM_OpenSSL:BOOL=ON \
    -DSlicer_USE_SimpleITK:BOOL=OFF

Getting errors like this:

dlopen(/Users/herzc/D/S4D/Slicer-build/lib/Slicer-4.13/qt-loadable-modules/qSlicerVolumeRenderingModuleWidgetsPythonQt.so, 0x0001): Symbol not found: __ZSt9terminatev
  Referenced from: /Users/herzc/D/S4D/Slicer-build/lib/Slicer-4.13/qt-loadable-modules/qSlicerVolumeRenderingModuleWidgetsPythonQt.so
  Expected in: /Users/herzc/D/S4D/ITK-build/lib/libITKDiffusionTensorImage-5.2.1.dylib
dlopen(/Users/herzc/D/S4D/Slicer-build/lib/Slicer-4.13/qt-loadable-modules/qSlicerDICOMLibModuleWidgetsPythonQt.so, 0x0001): Symbol not found: __ZSt9terminatev
  Referenced from: /Users/herzc/D/S4D/Slicer-build/lib/Slicer-4.13/qt-loadable-modules/qSlicerDICOMLibModuleWidgetsPythonQt.so
  Expected in: /Users/herzc/D/S4D/ITK-build/lib/libitklbfgs-5.2.1.dylib
dlopen(/Users/herzc/D/S4D/Slicer-build/lib/Slicer-4.13/qt-loadable-modules/qSlicerTablesModuleWidgetsPythonQt.so, 0x0001): Symbol not found: __ZSt9terminatev
  Referenced from: /Users/herzc/D/S4D/Slicer-build/lib/Slicer-4.13/qt-loadable-modules/qSlicerTablesModuleWidgetsPythonQt.so
  Expected in: /Users/herzc/D/S4D/ITK-build/lib/libITKOptimizersv4-5.2.1.dylib

I am using Qt from the online installer but can also try again with the one installed from brew (but Qt designer doesn’t work with that one)

I will try again with the cmake configuration from here: Slicer build on macOS Monterey - #6 by hherhold

Something relatively recent changed; I can build a fork from late January but the latest master fails.

The build machine looks okay though, I wonder if it’s a Monterey thing with some recent update?

Building an early Jan version works, but I am still getting the same errors when starting Slicer.

I will try with your configuration.

I looked through the 85 or so commits between the branch I have from late January (I said fork before, sorry, meant branch) and master from today, but nothing was obvious. I might try a binary search and see what broke things, I’ll let you know if I get to this.

Thanks - let us know what you find. I haven’t had a chance to try building since my mac (and my brain) are tied up with some other projects.

It looks like it was this one (below). The errors I get are the ones above, and included below for completeness.

And the build error:

[ 15%] Built target vtkITK
[ 15%] Building CXX object Libs/vtkITK/CMakeFiles/vtkITKPython.dir/vtkITKGradientAnisotropicDiffusionImageFilterPython.cxx.o
In file included from /opt/SB/build-test/Slicer-build/Libs/vtkITK/vtkITKGradientAnisotropicDiffusionImageFilterPython.cxx:10:
In file included from /opt/SB/Slicer/Libs/vtkITK/vtkITKGradientAnisotropicDiffusionImageFilter.h:18:
In file included from /opt/SB/Slicer/Libs/vtkITK/vtkITKImageToImageFilterFF.h:21:
In file included from /opt/SB/build-test/ITK/Modules/Bridge/VTK/include/itkVTKImageExport.h:143:
In file included from /opt/SB/build-test/ITK/Modules/Bridge/VTK/include/itkVTKImageExport.hxx:27:
In file included from /opt/SB/build-test/ITK/Modules/Core/Common/include/itkNumericTraitsDiffusionTensor3DPixel.h:22:
In file included from /opt/SB/build-test/ITK/Modules/Core/Common/include/itkDiffusionTensor3D.h:26:
In file included from /opt/SB/build-test/ITK/Modules/Core/Common/include/itkSymmetricSecondRankTensor.h:29:
/opt/SB/build-test/ITK/Modules/Core/Common/include/itkSymmetricEigenAnalysis.h:156:1: warning: control may reach end of non-void function [-Wreturn-type]
}
^
In file included from /opt/SB/build-test/Slicer-build/Libs/vtkITK/vtkITKGradientAnisotropicDiffusionImageFilterPython.cxx:10:
In file included from /opt/SB/Slicer/Libs/vtkITK/vtkITKGradientAnisotropicDiffusionImageFilter.h:19:
In file included from /opt/SB/build-test/ITK/Modules/Filtering/AnisotropicSmoothing/include/itkGradientAnisotropicDiffusionImageFilter.h:21:
In file included from /opt/SB/build-test/ITK/Modules/Filtering/AnisotropicSmoothing/include/itkAnisotropicDiffusionImageFilter.h:21:
In file included from /opt/SB/build-test/ITK/Modules/Core/FiniteDifference/include/itkDenseFiniteDifferenceImageFilter.h:21:
In file included from /opt/SB/build-test/ITK/Modules/Core/FiniteDifference/include/itkFiniteDifferenceImageFilter.h:21:
In file included from /opt/SB/build-test/ITK/Modules/Core/Common/include/itkInPlaceImageFilter.h:189:
/opt/SB/build-test/ITK/Modules/Core/Common/include/itkInPlaceImageFilter.hxx:97:5: error: use of undeclared identifier '__ASSERT_FUNCTION'
    itkAssertOrThrowMacro(inputAsOutput.IsNotNull(), "Unable to convert input image to output image as expected!");
    ^
/opt/SB/build-test/ITK/Modules/Core/Common/include/itkMacro.h:754:5: note: expanded from macro 'itkAssertOrThrowMacro'
    itkAssertInDebugOrThrowInReleaseMacro(msgstr.str().c_str());                                                       \
    ^
/opt/SB/build-test/ITK/Modules/Core/Common/include/itkMacro.h:740:95: note: expanded from macro 'itkAssertInDebugOrThrowInReleaseMacro'
#    define itkAssertInDebugOrThrowInReleaseMacro(msg) __assert_fail(msg, __FILE__, __LINE__, __ASSERT_FUNCTION);
                                                                                              ^
In file included from /opt/SB/build-test/Slicer-build/Libs/vtkITK/vtkITKGradientAnisotropicDiffusionImageFilterPython.cxx:10:
In file included from /opt/SB/Slicer/Libs/vtkITK/vtkITKGradientAnisotropicDiffusionImageFilter.h:19:
In file included from /opt/SB/build-test/ITK/Modules/Filtering/AnisotropicSmoothing/include/itkGradientAnisotropicDiffusionImageFilter.h:21:
In file included from /opt/SB/build-test/ITK/Modules/Filtering/AnisotropicSmoothing/include/itkAnisotropicDiffusionImageFilter.h:21:
In file included from /opt/SB/build-test/ITK/Modules/Core/FiniteDifference/include/itkDenseFiniteDifferenceImageFilter.h:21:
In file included from /opt/SB/build-test/ITK/Modules/Core/FiniteDifference/include/itkFiniteDifferenceImageFilter.h:380:
In file included from /opt/SB/build-test/ITK/Modules/Core/FiniteDifference/include/itkFiniteDifferenceImageFilter.hxx:21:
In file included from /opt/SB/build-test/ITK/Modules/Core/Common/include/itkImageRegionIterator.h:21:
In file included from /opt/SB/build-test/ITK/Modules/Core/Common/include/itkImageRegionConstIterator.h:21:
In file included from /opt/SB/build-test/ITK/Modules/Core/Common/include/itkImageIterator.h:21:
/opt/SB/build-test/ITK/Modules/Core/Common/include/itkImageConstIterator.h:210:7: error: use of undeclared identifier '__ASSERT_FUNCTION'
      itkAssertOrThrowMacro((bufferedRegion.IsInside(m_Region)),
      ^
/opt/SB/build-test/ITK/Modules/Core/Common/include/itkMacro.h:754:5: note: expanded from macro 'itkAssertOrThrowMacro'
    itkAssertInDebugOrThrowInReleaseMacro(msgstr.str().c_str());                                                       \
    ^
/opt/SB/build-test/ITK/Modules/Core/Common/include/itkMacro.h:740:95: note: expanded from macro 'itkAssertInDebugOrThrowInReleaseMacro'
#    define itkAssertInDebugOrThrowInReleaseMacro(msg) __assert_fail(msg, __FILE__, __LINE__, __ASSERT_FUNCTION);
                                                                                              ^
1 warning and 2 errors generated.
make[5]: *** [Libs/vtkITK/CMakeFiles/vtkITKPython.dir/vtkITKGradientAnisotropicDiffusionImageFilterPython.cxx.o] Error 1
make[4]: *** [Libs/vtkITK/CMakeFiles/vtkITKPython.dir/all] Error 2
make[3]: *** [all] Error 2
make[2]: *** [Slicer-prefix/src/Slicer-stamp/Slicer-build] Error 2
make[1]: *** [CMakeFiles/Slicer.dir/all] Error 2
make: *** [all] Error 2

Also, why the nightly builds aren’t broken, I have no idea. My guess is that machine isn’t running Monterey? I’m running 12.1 right now.

Hi Steve @pieper ,

I saw the change to ITK in the most recent commit but I still get this error, the failing target is vtkITKPython. Any ideas?

Thanks!

I tried compiling again and getting the same errors:

In file included from /Users/herzc/D/S4DD/ITK/Modules/Core/Common/include/itkInPlaceImageFilter.h:189:
/Users/herzc/D/S4DD/ITK/Modules/Core/Common/include/itkInPlaceImageFilter.hxx:93:5: error: use of undeclared identifier '__ASSERT_FUNCTION'
    itkAssertOrThrowMacro(inputAsOutput.IsNotNull(), "Unable to convert input image to output image as expected!");
    ^
/Users/herzc/D/S4DD/ITK/Modules/Core/Common/include/itkMacro.h:794:5: note: expanded from macro 'itkAssertOrThrowMacro'
    itkAssertInDebugOrThrowInReleaseMacro(msgstr.str().c_str()); \
    ^
/Users/herzc/D/S4DD/ITK/Modules/Core/Common/include/itkMacro.h:780:95: note: expanded from macro 'itkAssertInDebugOrThrowInReleaseMacro'
#    define itkAssertInDebugOrThrowInReleaseMacro(msg) __assert_fail(msg, __FILE__, __LINE__, __ASSERT_FUNCTION);
                                                                                              ^
In file included from /Users/herzc/D/S4DD/Slicer-build/Libs/vtkITK/vtkITKGradientAnisotropicDiffusionImageFilterPython.cxx:10:
In file included from /Users/herzc/sources/cpp/Slicer/Libs/vtkITK/vtkITKGradientAnisotropicDiffusionImageFilter.h:19:
In file included from /Users/herzc/D/S4DD/ITK/Modules/Filtering/AnisotropicSmoothing/include/itkGradientAnisotropicDiffusionImageFilter.h:21:
In file included from /Users/herzc/D/S4DD/ITK/Modules/Filtering/AnisotropicSmoothing/include/itkAnisotropicDiffusionImageFilter.h:21:
In file included from /Users/herzc/D/S4DD/ITK/Modules/Core/FiniteDifference/include/itkDenseFiniteDifferenceImageFilter.h:21:
In file included from /Users/herzc/D/S4DD/ITK/Modules/Core/FiniteDifference/include/itkFiniteDifferenceImageFilter.h:380:
In file included from /Users/herzc/D/S4DD/ITK/Modules/Core/FiniteDifference/include/itkFiniteDifferenceImageFilter.hxx:21:
In file included from /Users/herzc/D/S4DD/ITK/Modules/Core/Common/include/itkImageRegionIterator.h:21:
In file included from /Users/herzc/D/S4DD/ITK/Modules/Core/Common/include/itkImageRegionConstIterator.h:21:
In file included from /Users/herzc/D/S4DD/ITK/Modules/Core/Common/include/itkImageIterator.h:21:
/Users/herzc/D/S4DD/ITK/Modules/Core/Common/include/itkImageConstIterator.h:210:7: error: use of undeclared identifier '__ASSERT_FUNCTION'
      itkAssertOrThrowMacro((bufferedRegion.IsInside(m_Region)),
      ^
/Users/herzc/D/S4DD/ITK/Modules/Core/Common/include/itkMacro.h:794:5: note: expanded from macro 'itkAssertOrThrowMacro'
    itkAssertInDebugOrThrowInReleaseMacro(msgstr.str().c_str()); \
    ^
/Users/herzc/D/S4DD/ITK/Modules/Core/Common/include/itkMacro.h:780:95: note: expanded from macro 'itkAssertInDebugOrThrowInReleaseMacro'
#    define itkAssertInDebugOrThrowInReleaseMacro(msg) __assert_fail(msg, __FILE__, __LINE__, __ASSERT_FUNCTION);
                                                                                              ^
1 warning generated.
1 warning and 2 errors generated.
make[5]: *** [Libs/vtkITK/CMakeFiles/vtkITKPython.dir/vtkITKGradientAnisotropicDiffusionImageFilterPython.cxx.o] Error 1
make[4]: *** [Libs/vtkITK/CMakeFiles/vtkITKPython.dir/all] Error 2

So far only reverting changes to early 2022 worked for me.

Not a conflicting assert header in your path? re c++ - Message "error: use of undeclared identifier 'assert'" - Stack Overflow

@hherhold @che85

I’ve experienced the same issue on Monterey. I dug a little deeper, and it looks like the root cause is the preprocessor identifier _POSIX_SOURCE being defined during compile of vtkITK.This causes itkMacro.h file to conditionally include code which depends on Linux specific details of assert.h.

I sent a PR which uses the more granular __linux preprocessor identifier for this conditional to Slicer/ITK and once approved will duplicate this to the main ITK repository.

3 Likes

Good catch! This appears to work on my machine as well - vtkITKPython target was the one failing, and it just finished. Rest of the build proceeding.

Nicely done!