Building ITK: Error With Algorithim Module

Hello ITK Community,

I am attempting to rebuild the ITK project. I had a successful build on the same system before, but I am having problems with this rebuild (The previous build was completed with the VMTK super build tool).

Build Details: commit 79a2823dcd51489a926beb98edb89df60b629c39

CMake configures all elements correctly, but when I run

make -j 10

I get a wall of errors when I reach the itkMathematicalMorphologyEnums.cxx file all saying something along the lines of:

error: use of enum ‘Algorithm’ without previous declaration

I am not really sure how to approach this error as it looks like modification of the ITK source is required, but I am not experienced in it.

Thanks for any help in resolving this!

Which compiler are you using, and what exact version? Please copy the entire error message with notes, in particular the source file and line where it occurs.

itkMathematicalMorphologyEnums.h and itkMathematicalMorphologyEnums.cxx are so short and simple, it is hard to tell why anything would go wrong there.

Maybe on 25, replace const MathematicalMorphologyEnums::Algorithm value by const typename MathematicalMorphologyEnums::Algorithm value (note the addition of typename).

Hello Thanks for the reply:
Compilers:
C++ -->(GCC) 13.1.1 20230429
C → (GCC) 13.1.1 20230429
Error

ITK/Modules/Filtering/MathematicalMorphology/include/itkMathematicalMorphologyEnums.h:41:14: error: use of enum ‘Algorithm’ without previous declaration
   41 |   enum class Algorithm : uint8_t
      |              ^~~~~~~~~
ITK/Modules/Filtering/MathematicalMorphology/include/itkMathematicalMorphologyEnums.h:41:26: error: ‘uint8_t’ was not declared in this scope
   41 |   enum class Algorithm : uint8_t
      |                          ^~~~~~~
ITK/Modules/Filtering/MathematicalMorphology/include/itkMathematicalMorphologyEnums.h:23:1: note: ‘uint8_t’ is defined in header ‘<cstdint>’; did you forget to ‘#include <cstdint>’?
   22 | #include "ITKMathematicalMorphologyExport.h"
  +++ |+#include <cstdint>
   23 | 
ITK/Modules/Filtering/MathematicalMorphology/include/itkMathematicalMorphologyEnums.h:42:3: error: default member initializer for unnamed bit-field
   42 |   {
      |   ^
ITK/Modules/Filtering/MathematicalMorphology/include/itkMathematicalMorphologyEnums.h:52:107: error: ‘Algorithm’ in ‘class itk::MathematicalMorphologyEnums’ does not name a type
   52 |                                         operator<<(std::ostream & out, const MathematicalMorphologyEnums::Algorithm value);
      |                                                                                                           ^~~~~~~~~
ITK/Modules/Filtering/MathematicalMorphology/src/itkMathematicalMorphologyEnums.cxx:25:67: error: ‘Algorithm’ in ‘class itk::MathematicalMorphologyEnums’ does not name a type
   25 | operator<<(std::ostream & out, const MathematicalMorphologyEnums::Algorithm value)
      |                                                                   ^~~~~~~~~
ITK/Modules/Filtering/MathematicalMorphology/src/itkMathematicalMorphologyEnums.cxx: In lambda function:
ITK/Modules/Filtering/MathematicalMorphology/src/itkMathematicalMorphologyEnums.cxx:30:41: error: ‘itk::MathematicalMorphologyEnums::Algorithm’ has not been declared
   30 |       case MathematicalMorphologyEnums::Algorithm::BASIC:
      |                                         ^~~~~~~~~
ITK/Modules/Filtering/MathematicalMorphology/src/itkMathematicalMorphologyEnums.cxx:32:41: error: ‘itk::MathematicalMorphologyEnums::Algorithm’ has not been declared
   32 |       case MathematicalMorphologyEnums::Algorithm::HISTO:
      |                                         ^~~~~~~~~
ITK/Modules/Filtering/MathematicalMorphology/src/itkMathematicalMorphologyEnums.cxx:34:41: error: ‘itk::MathematicalMorphologyEnums::Algorithm’ has not been declared
   34 |       case MathematicalMorphologyEnums::Algorithm::ANCHOR:
      |                                         ^~~~~~~~~
ITK/Modules/Filtering/MathematicalMorphology/src/itkMathematicalMorphologyEnums.cxx:36:41: error: ‘itk::MathematicalMorphologyEnums::Algorithm’ has not been declared
   36 |       case MathematicalMorphologyEnums::Algorithm::VHGW:
      |                                         ^~~~~~~~~
make[2]: *** [Modules/Filtering/MathematicalMorphology/src/CMakeFiles/ITKMathematicalMorphology.dir/build.make:76: Modules/Filtering/MathematicalMorphology/src/CMakeFiles/ITKMathematicalMorphology.dir/itkMathematicalMorphologyEnums.cxx.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:16833: Modules/Filtering/MathematicalMorphology/src/CMakeFiles/ITKMathematicalMorphology.dir/all] Error 2

If you change line 41 to read enum class Algorithm : std::uint8_t, does that fix it?

GCC 13.1 is very new, I guess no one tested compiling ITK with it before.

1 Like

I assume this will not be the only error. @blowekamp @hjmjohnson do you have time to make ITK compile with GCC 13?

To clarify to you mean modify line 41 to be:

}(enum class Algorithinm : std::uint8_t);

or

(enum class Algorithinm : std::uint8_t);

Line 41:

does not have any parentheses or braces for me.

My apologies I was editing the .cxx not the .h.

Making that change as well as adding

#include <cstdint>

fixed the problem for me, no other build errors.

I can submit a PR if the devs want thank you for your help and fast replies!

1 Like

Please do submit the PR. See contribution guidelines.

Created waiting for approval, I tried to tag you in the request, but I could not find your github username please share if possible.

Hi, I also compile itk from the source with gcc 13, and got /usr/include/stdlib.h:252:4: error: unknown type name '_Float32x' errors. here is the complete build log.
log.txt (266.9 KB)
The first error occurs at line 3210.
I can confirm that this pr is included.

I found a thread that user encounter similar error with gcc 13, but they’re using cuda. Strange errors after system gcc upgraded to 13.1.1 - #3 by Sanhu_Li - nvc, nvc++ and nvfortran - NVIDIA Developer Forums

You are building ITK from a package manager (looks like pacman), clone the git repository yourself and try to install as I can not confirm that the build procedure for ITK from pacman works.

Ok, I could build it with gcc 12.

Was this with you cloning the github repo or from your package manager?

To build with GCC 13 just patch :slight_smile:
— InsightToolkit-4.13.2.orig/Modules/ThirdParty/VNL/src/vxl/vcl/vcl_compiler.h
+++ InsightToolkit-4.13.2/Modules/ThirdParty/VNL/src/vxl/vcl/vcl_compiler.h

+# elif (GNUC==13)
+# define VCL_GCC_13
+# if (GNUC_MINOR > 2 )
+# define VCL_GCC_133
+# elif (GNUC_MINOR > 1 )
+# define VCL_GCC_132
+# elif (GNUC_MINOR > 0 )
+# define VCL_GCC_131
+# else
+# define VCL_GCC_130
+# endif

else

error “Dunno about this gcc”

endif

To compile with GCC13 and Higher I just add New compiler versions :slight_smile:

patch -p1 <<‘endpatch’
— InsightToolkit-4.13.2.orig/Modules/ThirdParty/VNL/src/vxl/vcl/vcl_compiler.h
+++ InsightToolkit-4.13.2/Modules/ThirdParty/VNL/src/vxl/vcl/vcl_compiler.h
@@ -97,6 +97,50 @@

else

define VCL_GCC_80

endif

+# elif (GNUC==9)
+# define VCL_GCC_9
+# if (GNUC_MINOR > 2 )
+# define VCL_GCC_93
+# elif (GNUC_MINOR > 1 )
+# define VCL_GCC_92
+# elif (GNUC_MINOR > 0 )
+# define VCL_GCC_91
+# else
+# define VCL_GCC_90
+# endif
+# elif (GNUC==10)
+# define VCL_GCC_10
+# if (GNUC_MINOR > 2 )
+# define VCL_GCC_103
+# elif (GNUC_MINOR > 1 )
+# define VCL_GCC_102
+# elif (GNUC_MINOR > 0 )
+# define VCL_GCC_101
+# else
+# define VCL_GCC_100
+# endif
+# elif (GNUC==11)
+# define VCL_GCC_11
+# if (GNUC_MINOR > 2 )
+# define VCL_GCC_113
+# elif (GNUC_MINOR > 1 )
+# define VCL_GCC_112
+# elif (GNUC_MINOR > 0 )
+# define VCL_GCC_111
+# else
+# define VCL_GCC_110
+# endif
+# elif (GNUC==12)
+# define VCL_GCC_12
+# if (GNUC_MINOR > 2 )
+# define VCL_GCC_123
+# elif (GNUC_MINOR > 1 )
+# define VCL_GCC_122
+# elif (GNUC_MINOR > 0 )
+# define VCL_GCC_121
+# else
+# define VCL_GCC_120
+# endif
+# elif (GNUC==13)
+# define VCL_GCC_13
+# if (GNUC_MINOR > 2 )
+# define VCL_GCC_133
+# elif (GNUC_MINOR > 1 )
+# define VCL_GCC_132
+# elif (GNUC_MINOR > 0 )
+# define VCL_GCC_131
+# else
+# define VCL_GCC_130
+# endif

else

error “Dunno about this gcc”

endif

endpatch

This is useful information @Wayne_Marshall. Could you turn it into a PR as per contribution guidelines?