# Compile error using code from itkMontage module.

**URL:** https://discourse.itk.org/t/compile-error-using-code-from-itkmontage-module/2186
**Category:** Beginner Questions
**Created:** [August 21, 2019, 3:59pm UTC](https://discourse.itk.org/t/compile-error-using-code-from-itkmontage-module/2186 "2019-08-21T15:59:59Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![spic](https://discourse.itk.org/letter_avatar_proxy/v4/letter/s/ea5d25/32.png) [@spic](https://discourse.itk.org/u/spic)
#### Post date: [August 21, 2019, 3:59pm UTC](https://discourse.itk.org/t/compile-error-using-code-from-itkmontage-module/2186/1 "2019-08-21T15:59:59Z")

</div>

I am trying to run example code given in itkMontage module from [here](https://github.com/InsightSoftwareConsortium/ITKMontage/blob/d48b400cea8d96f1db51829f0d3a6596e4da2c78/examples/RefineMontage2D.cxx#L32). 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 );  
> ^

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [August 21, 2019, 4:53pm UTC](https://discourse.itk.org/t/compile-error-using-code-from-itkmontage-module/2186/2 "2019-08-21T16:53:39Z")

</div>

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

---

<div class="post-metadata">

### Author: ![spic](https://discourse.itk.org/letter_avatar_proxy/v4/letter/s/ea5d25/32.png) [@spic](https://discourse.itk.org/u/spic)
#### Post date: [August 21, 2019, 5:05pm UTC](https://discourse.itk.org/t/compile-error-using-code-from-itkmontage-module/2186/3 "2019-08-21T17:05:01Z")

</div>

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

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [August 21, 2019, 6:06pm UTC](https://discourse.itk.org/t/compile-error-using-code-from-itkmontage-module/2186/4 "2019-08-21T18:06:27Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [August 21, 2019, 7:54pm UTC](https://discourse.itk.org/t/compile-error-using-code-from-itkmontage-module/2186/5 "2019-08-21T19:54:31Z")

</div>

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

---

<div class="post-metadata">

### Author: ![spic](https://discourse.itk.org/letter_avatar_proxy/v4/letter/s/ea5d25/32.png) [@spic](https://discourse.itk.org/u/spic)
#### Post date: [August 21, 2019, 8:03pm UTC](https://discourse.itk.org/t/compile-error-using-code-from-itkmontage-module/2186/6 "2019-08-21T20:03:03Z")

</div>

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

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [August 21, 2019, 8:28pm UTC](https://discourse.itk.org/t/compile-error-using-code-from-itkmontage-module/2186/7 "2019-08-21T20:28:08Z")

</div>

I am also getting that compile error with GCC-4.8.5. Since the [point of instantiation](https://github.com/InsightSoftwareConsortium/ITKMontage/blob/d48b400cea8d96f1db51829f0d3a6596e4da2c78/include/itkMaxPhaseCorrelationOptimizer.h#L125) does not involve `const`, this might be a bug in GCC 4.8.5.

GCC 5.4.0 has no problem with it.
