SuperElastix / SimpleElastix

Multi-lingual medical image registration library
http://simpleelastix.github.io
Apache License 2.0
509 stars 149 forks source link

Superbuild fails on Ubuntu 20.04 - GDCM compilation? #450

Open silgonel opened 2 years ago

silgonel commented 2 years ago

Hello,

I am trying to follow instructions here (https://simpleelastix.readthedocs.io/GettingStarted.html) to install SimpleElastix, but I get stuck at the "make -j4" step. The error log is printed below.

I saw some related issue here (https://github.com/SimpleITK/SimpleITK/issues/1435) for SimpleITK, but I don't understand how to solve it for simple-elastix compilation.

If anyone has any hint, it would be very appreciated! Many thanks, Silvia


[ 58%] Building CXX object Modules/ThirdParty/GDCM/src/gdcm/Source/MediaStorageAndFileFormat/CMakeFiles/gdcmMSFF.dir/gdcmImageChangePhotometricInterpretation.cxx.o In file included from /home/silvia/build/ITK/Modules/ThirdParty/GDCM/src/gdcm/Source/MediaStorageAndFileFormat/gdcmImageChangePhotometricInterpretation.cxx:14: /home/silvia/build/ITK/Modules/ThirdParty/GDCM/src/gdcm/Source/MediaStorageAndFileFormat/gdcmImageChangePhotometricInterpretation.h: In function ‘T gdcm::Clamp(int)’: /home/silvia/build/ITK/Modules/ThirdParty/GDCM/src/gdcm/Source/MediaStorageAndFileFormat/gdcmImageChangePhotometricInterpretation.h:67:32: error: ‘numeric_limits’ is not a member of ‘std’ 67 | return v < 0 ? 0 : (v > std::numeric_limits::max() ? std::numeric_limits::max() : v); | ^~~~~~ /home/silvia/build/ITK/Modules/ThirdParty/GDCM/src/gdcm/Source/MediaStorageAndFileFormat/gdcmImageChangePhotometricInterpretation.h:67:48: error: expected primary-expression before ‘>’ token 67 | return v < 0 ? 0 : (v > std::numeric_limits::max() ? std::numeric_limits::max() : v); | ^ /home/silvia/build/ITK/Modules/ThirdParty/GDCM/src/gdcm/Source/MediaStorageAndFileFormat/gdcmImageChangePhotometricInterpretation.h:67:51: error: ‘::max’ has not been declared; did you mean ‘std::max’? 67 | return v < 0 ? 0 : (v > std::numeric_limits::max() ? std::numeric_limits::max() : v); | ^~~ | std::max In file included from /usr/include/c++/11/algorithm:62, from /home/silvia/build/ITK/Modules/ThirdParty/GDCM/src/gdcm/Source/DataStructureAndEncodingDefinition/gdcmByteValue.h:24, from /home/silvia/build/ITK/Modules/ThirdParty/GDCM/src/gdcm/Source/DataStructureAndEncodingDefinition/gdcmDataElement.h:20, from /home/silvia/build/ITK/Modules/ThirdParty/GDCM/src/gdcm/Source/MediaStorageAndFileFormat/gdcmBitmap.h:19, from /home/silvia/build/ITK/Modules/ThirdParty/GDCM/src/gdcm/Source/MediaStorageAndFileFormat/gdcmBitmapToBitmapFilter.h:17, from /home/silvia/build/ITK/Modules/ThirdParty/GDCM/src/gdcm/Source/MediaStorageAndFileFormat/gdcmPixmapToPixmapFilter.h:17, from /home/silvia/build/ITK/Modules/ThirdParty/GDCM/src/gdcm/Source/MediaStorageAndFileFormat/gdcmImageToImageFilter.h:17, from /home/silvia/build/ITK/Modules/ThirdParty/GDCM/src/gdcm/Source/MediaStorageAndFileFormat/gdcmImageChangePhotometricInterpretation.h:17, from /home/silvia/build/ITK/Modules/ThirdParty/GDCM/src/gdcm/Source/MediaStorageAndFileFormat/gdcmImageChangePhotometricInterpretation.cxx:14: /usr/include/c++/11/bits/stl_algo.h:3467:5: note: ‘std::max’ declared here 3467 | max(initializer_list<_Tp> l, _Compare comp) | ^~~ In file included from /home/silvia/build/ITK/Modules/ThirdParty/GDCM/src/gdcm/Source/MediaStorageAndFileFormat/gdcmImageChangePhotometricInterpretation.cxx:14: /home/silvia/build/ITK/Modules/ThirdParty/GDCM/src/gdcm/Source/MediaStorageAndFileFormat/gdcmImageChangePhotometricInterpretation.h:67:64: error: ‘numeric_limits’ is not a member of ‘std’ 67 | return v < 0 ? 0 : (v > std::numeric_limits::max() ? std::numeric_limits::max() : v); | ^~~~~~ /home/silvia/build/ITK/Modules/ThirdParty/GDCM/src/gdcm/Source/MediaStorageAndFileFormat/gdcmImageChangePhotometricInterpretation.h:67:80: error: expected primary-expression before ‘>’ token 67 | return v < 0 ? 0 : (v > std::numeric_limits::max() ? std::numeric_limits::max() : v); | ^ /home/silvia/build/ITK/Modules/ThirdParty/GDCM/src/gdcm/Source/MediaStorageAndFileFormat/gdcmImageChangePhotometricInterpretation.h:67:83: error: ‘::max’ has not been declared; did you mean ‘std::max’? 67 | return v < 0 ? 0 : (v > std::numeric_limits::max() ? std::numeric_limits::max() : v); | ^~~ | std::max In file included from /usr/include/c++/11/algorithm:62, from /home/silvia/build/ITK/Modules/ThirdParty/GDCM/src/gdcm/Source/DataStructureAndEncodingDefinition/gdcmByteValue.h:24, from /home/silvia/build/ITK/Modules/ThirdParty/GDCM/src/gdcm/Source/DataStructureAndEncodingDefinition/gdcmDataElement.h:20, from /home/silvia/build/ITK/Modules/ThirdParty/GDCM/src/gdcm/Source/MediaStorageAndFileFormat/gdcmBitmap.h:19, from /home/silvia/build/ITK/Modules/ThirdParty/GDCM/src/gdcm/Source/MediaStorageAndFileFormat/gdcmBitmapToBitmapFilter.h:17, from /home/silvia/build/ITK/Modules/ThirdParty/GDCM/src/gdcm/Source/MediaStorageAndFileFormat/gdcmPixmapToPixmapFilter.h:17, from /home/silvia/build/ITK/Modules/ThirdParty/GDCM/src/gdcm/Source/MediaStorageAndFileFormat/gdcmImageToImageFilter.h:17, from /home/silvia/build/ITK/Modules/ThirdParty/GDCM/src/gdcm/Source/MediaStorageAndFileFormat/gdcmImageChangePhotometricInterpretation.h:17, from /home/silvia/build/ITK/Modules/ThirdParty/GDCM/src/gdcm/Source/MediaStorageAndFileFormat/gdcmImageChangePhotometricInterpretation.cxx:14: /usr/include/c++/11/bits/stl_algo.h:3467:5: note: ‘std::max’ declared here 3467 | max(initializer_list<_Tp> l, _Compare comp) | ^~~ make[5]: [Modules/ThirdParty/GDCM/src/gdcm/Source/MediaStorageAndFileFormat/CMakeFiles/gdcmMSFF.dir/build.make:482: Modules/ThirdParty/GDCM/src/gdcm/Source/MediaStorageAndFileFormat/CMakeFiles/gdcmMSFF.dir/gdcmImageChangePhotometricInterpretation.cxx.o] Error 1 make[4]: [CMakeFiles/Makefile2:8314: Modules/ThirdParty/GDCM/src/gdcm/Source/MediaStorageAndFileFormat/CMakeFiles/gdcmMSFF.dir/all] Error 2 make[3]: [Makefile:156: all] Error 2 make[2]: [CMakeFiles/ITK.dir/build.make:86: ITK-prefix/src/ITK-stamp/ITK-build] Error 2 make[1]: [CMakeFiles/Makefile2:335: CMakeFiles/ITK.dir/all] Error 2 make: [Makefile:91: all] Error 2

franciscomcm commented 2 years ago

Hi Silvia,

I am also trying to build SimpleElastix and managed to fix this error by adjusting the versions of ITK and SimpleITK downloaded in the process.

As indicated in the related issue you shared, this error should be fixed in ITK v5.2.1. However, the version of SimpleITK also has to be adjusted to a release compatible with ITK v5.2.1, which should be 2.1.1 (see here).

In practical terms, this is what I did:

  1. After cloning the repository, edit lines 11-13 of the file Version.cmake to define SimpleITK version 2.1.1.
  2. Enter the SuperBuild folder and edit line 56 of External_ITK.cmake to v5.2.1.

After fixing this, there was still some issue with elastix so I also edited line 5 of the file External_Elastix.cmake to the Git Commit tag corresponding to the release of elastix v5.0.1: 90122eff6b37a17adc9f5bb3d7bc08608e9c14a6, which you can confirm here.

Unfortunately, these changes were not sufficient for me. The build reaches 100% but fails before completing with a linker error, which I have not been able to solve yet:

[100%] Building CXX object Wrapping/Python/CMakeFiles/SimpleITK_PYTHON.dir/sitkPyCommand.cxx.o
[100%] Building CXX object Wrapping/Python/CMakeFiles/SimpleITK_PYTHON.dir/SimpleITKPYTHON_wrap.cxx.o
[100%] Linking CXX shared module _SimpleITK.so
/usr/bin/ld.gold: error: cannot find -lelastix
/usr/bin/ld.gold: error: cannot find -ltransformix
collect2: error: ld returned 1 exit status
make[5]: *** [Wrapping/Python/CMakeFiles/SimpleITK_PYTHON.dir/build.make:656: Wrapping/Python/_SimpleITK.so] Error 1
make[4]: *** [CMakeFiles/Makefile2:1986: Wrapping/Python/CMakeFiles/SimpleITK_PYTHON.dir/all] Error 2
make[3]: *** [Makefile:156: all] Error 2
make[2]: *** [CMakeFiles/SimpleITK.dir/build.make:88: SimpleITK-prefix/src/SimpleITK-stamp/SimpleITK-build] Error 2
make[1]: *** [CMakeFiles/Makefile2:185: CMakeFiles/SimpleITK.dir/all] Error 2
make: *** [Makefile:91: all] Error 2

Maybe this error doesn't occur in your system. I tried on macOS Big Sur v11.6 (Apple clang version 12.0.0) and Fedora release 34 (clang version 12.0.1, gcc 11.2.1, GNU ld version 2.35.2-6.fc34).

I hope it helps!