Problems with running HelloWorld project from documentation

Hi there!

I am just starting to learn about ITK so I’ve decided to start scanning documentation and learn as much as possible. While following instructions specified in section 2.5.1. I ran into following error:

stefan@stefan-VirtualBox:~/Desktop/ITK-Training/HelloWorldITK-build$ cmake --build . 
Scanning dependencies of target HelloWorld
[ 50%] Building CXX object CMakeFiles/HelloWorld.dir/HelloWorld.o
In file included from /usr/local/include/ITK-4.6/vnl/vnl_c_vector.h:26,
                 from /usr/local/include/ITK-4.6/vnl/vnl_vector.h:22,
                 from /usr/local/include/ITK-4.6/vnl/vnl_vector_ref.h:20,
                 from /usr/local/include/ITK-4.6/itkVector.h:23,
                 from /usr/local/include/ITK-4.6/itkPoint.h:23,
                 from /usr/local/include/ITK-4.6/itkContinuousIndex.h:21,
                 from /usr/local/include/ITK-4.6/itkImageRegion.h:34,
                 from /usr/local/include/ITK-4.6/itkImage.h:21,
                 from /home/stefan/Desktop/ITK-Training/HelloWorldITK/HelloWorld.cxx:1:
/usr/local/include/ITK-4.6/vnl/vnl_numeric_traits.h:387:22: error: ‘constexpr’ needed for in-class initialization of static data member ‘const float vnl_numeric_traits<float>::zero’ of non-integral type [-fpermissive]
  387 |   static const float zero VCL_STATIC_CONST_INIT_FLOAT_DECL(0.0F);
      |                      ^~~~
/usr/local/include/ITK-4.6/vnl/vnl_numeric_traits.h:389:22: error: ‘constexpr’ needed for in-class initialization of static data member ‘const float vnl_numeric_traits<float>::one’ of non-integral type [-fpermissive]
  389 |   static const float one VCL_STATIC_CONST_INIT_FLOAT_DECL(1.0F);
      |                      ^~~
/usr/local/include/ITK-4.6/vnl/vnl_numeric_traits.h:391:22: error: ‘constexpr’ needed for in-class initialization of static data member ‘const float vnl_numeric_traits<float>::maxval’ of non-integral type [-fpermissive]
  391 |   static const float maxval VCL_STATIC_CONST_INIT_FLOAT_DECL(3.40282346638528860e+38F);
      |                      ^~~~~~
/usr/local/include/ITK-4.6/vnl/vnl_numeric_traits.h:410:23: error: ‘constexpr’ needed for in-class initialization of static data member ‘const double vnl_numeric_traits<double>::zero’ of non-integral type [-fpermissive]
  410 |   static const double zero VCL_STATIC_CONST_INIT_FLOAT_DECL(0.0);
      |                       ^~~~
/usr/local/include/ITK-4.6/vnl/vnl_numeric_traits.h:412:23: error: ‘constexpr’ needed for in-class initialization of static data member ‘const double vnl_numeric_traits<double>::one’ of non-integral type [-fpermissive]
  412 |   static const double one VCL_STATIC_CONST_INIT_FLOAT_DECL(1.0);
      |                       ^~~
/usr/local/include/ITK-4.6/vnl/vnl_numeric_traits.h:414:23: error: ‘constexpr’ needed for in-class initialization of static data member ‘const double vnl_numeric_traits<double>::maxval’ of non-integral type [-fpermissive]
  414 |   static const double maxval VCL_STATIC_CONST_INIT_FLOAT_DECL(1.7976931348623157E+308);
      |                       ^~~~~~
/usr/local/include/ITK-4.6/vnl/vnl_numeric_traits.h:433:28: error: ‘constexpr’ needed for in-class initialization of static data member ‘const long double vnl_numeric_traits<long double>::zero’ of non-integral type [-fpermissive]
  433 |   static const long double zero VCL_STATIC_CONST_INIT_FLOAT_DECL(0.0);
      |                            ^~~~
/usr/local/include/ITK-4.6/vnl/vnl_numeric_traits.h:435:28: error: ‘constexpr’ needed for in-class initialization of static data member ‘const long double vnl_numeric_traits<long double>::one’ of non-integral type [-fpermissive]
  435 |   static const long double one VCL_STATIC_CONST_INIT_FLOAT_DECL(1.0);
      |                            ^~~
/usr/local/include/ITK-4.6/vnl/vnl_numeric_traits.h:437:28: error: ‘constexpr’ needed for in-class initialization of static data member ‘const long double vnl_numeric_traits<long double>::maxval’ of non-integral type [-fpermissive]
  437 |   static const long double maxval VCL_STATIC_CONST_INIT_FLOAT_DECL(1.7976931348623157E+308);
      |                            ^~~~~~
make[2]: *** [CMakeFiles/HelloWorld.dir/build.make:82: CMakeFiles/HelloWorld.dir/HelloWorld.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:95: CMakeFiles/HelloWorld.dir/all] Error 2
make: *** [Makefile:103: all] Error 2

The error seems to be in the first line of my C++ file, which includes itkImage header. Note that I’ve installed and need to use ITK 4.6 version due to compatibility reasons.

Version 4.6 is 6+ years old now. Either try a newer version or an older compiler.

1 Like