Compile error using code from itkMontage module.

I am trying to run example code given in itkMontage module from here. When I try to compile the code, I am getting the following error. Any pointers to how to solve this error would be a great help.

In file included from /home/leonard/include/ITK-5.0/itkMaxPhaseCorrelationOptimizer.h:21:0,
from /home/leonard/include/ITK-5.0/itkTileMontage.h:23,
from /home/leonard/Code/cpp/main.cpp:11:
/home/leonard/include/ITK-5.0/itkNMinimaMaximaImageCalculator.h: In instantiation of ‘static itk::NMinimaMaximaImageCalculator::Pointer itk::NMinimaMaximaImageCalculator::New() [with TInputImage = itk::Image<double, 2u>; itk::NMinimaMaximaImageCalculator::Pointer = itk::SmartPointer<itk::NMinimaMaximaImageCalculator<itk::Image<double, 2u> > >]’:
/home/leonard/include/ITK-5.0/itkMaxPhaseCorrelationOptimizer.h:117:80: required from ‘static itk::MaxPhaseCorrelationOptimizer::Pointer itk::MaxPhaseCorrelationOptimizer::New() [with TRegistrationMethod = itk::PhaseCorrelationImageRegistrationMethod<itk::Image<float, 2u>, itk::Image<float, 2u> >; itk::MaxPhaseCorrelationOptimizer::Pointer = itk::SmartPointer<itk::MaxPhaseCorrelationOptimizer<itk::PhaseCorrelationImageRegistrationMethod<itk::Image<float, 2u>, itk::Image<float, 2u> > > >]’
/home/leonard/include/ITK-5.0/itkTileMontage.h:262:77: required from ‘itk::TileMontage<TImageType, TCoordinate>::TileMontage() [with TImageType = itk::Image<float, 2u>; TCoordinate = float]’
/home/leonard/include/ITK-5.0/itkTileMontage.h:55:3: required from ‘static itk::TileMontage<TImageType, TCoordinate>::Pointer itk::TileMontage<TImageType, TCoordinate>::New() [with TImageType = itk::Image<float, 2u>; TCoordinate = float; itk::TileMontage<TImageType, TCoordinate>::Pointer = itk::SmartPointer<itk::TileMontage<itk::Image<float, 2u>, float> >]’
/home/leonard/Code/cpp/main.cpp:60:62: required from ‘void montage2D(const TileLayout2D&, itk::TileLayout2D&, const string&) [with PixelType = float; AccumulatePixelType = float; itk::TileLayout2D = std::vector<std::vector<itk::Tile<2u> > >; std::string = std::basic_string]’
/home/leonard/Code/cpp/main.cpp:94:144: required from here
/home/leonard/include/ITK-5.0/itkNMinimaMaximaImageCalculator.h:119:3: error: conversion from ‘itk::Image<double, 2u>::Pointer {aka itk::SmartPointer<itk::Image<double, 2u> >}’ to non-scalar type ‘itk::NMinimaMaximaImageCalculator<itk::Image<double, 2u> >::ImageConstPointer {aka itk::SmartPointer<const itk::Image<double, 2u> >}’ requested
** NMinimaMaximaImageCalculator() = default;**
In file included from /home/leonard/include/ITK-5.0/itkNumericTraits.h:21:0,
from /home/leonard/include/ITK-5.0/itkPoint.h:22,
from /home/leonard/include/ITK-5.0/itkParseTileConfiguration.h:27,
from /home/leonard/Code/cpp/main.cpp:4:
/home/leonard/include/ITK-5.0/itkNMinimaMaximaImageCalculator.h:53:3: note: synthesized method ‘itk::NMinimaMaximaImageCalculator::NMinimaMaximaImageCalculator() [with TInputImage = itk::Image<double, 2u>]’ first required here
itkNewMacro( Self );

It looks like the examples got slightly outdated again. I will fix it over the coming days.

Thanks @dzenanz. Could you outline what you think is broken… so that I can attempt a fix for my code.

This is essentially a conversion from non-const type to const type. Most likely a const keyword needs to be added somewhere. Please make a PR if you fix it.

This is a compile error, which I am not getting. Which compiler are you using?

This error happens for gcc-4.8 but not for gcc-7.4. It was dirving me crazy. Thanks!

I am also getting that compile error with GCC-4.8.5. Since the point of instantiation does not involve const, this might be a bug in GCC 4.8.5.

GCC 5.4.0 has no problem with it.