micmacIGN / micmac

Free open-source photogrammetry software tools
http://micmac.ensg.eu
Other
705 stars 151 forks source link

Compilations fails on GCC 11.1.0 (ARCH Linux): error: loop variable 'aVois' creates a copy from type 'const Pt2d<int>' #182

Open speters opened 3 years ago

speters commented 3 years ago

https://github.com/micmacIGN/micmac/blob/06c3039ce4189be6ccc2f0666be2b166d23a0d8e/src/uti_image/NewRechPH/cOneScaleImRechPH.cpp#L283

[  2%] Building CXX object src/CMakeFiles/elise.dir/uti_image/NewRechPH/cOneScaleImRechPH.cpp.o
micmac-git/src/micmac/src/uti_image/NewRechPH/cOneScaleImRechPH.cpp: In member function 'bool cOneScaleImRechPH::IsCol(int, const std::vector<std::vector<Pt2d<int> > >&, const Pt2di&)':
micmac-git/src/micmac/src/uti_image/NewRechPH/cOneScaleImRechPH.cpp:283:24: error: loop variable 'aVois' creates a copy from type 'const Pt2d<int>' [-Werror=range-loop-construct]
  283 |        for (const auto aVois : aVpt)
      |                        ^~~~~
micmac-git/src/micmac/src/uti_image/NewRechPH/cOneScaleImRechPH.cpp:283:24: note: use reference type to prevent copying
  283 |        for (const auto aVois : aVpt)
      |                        ^~~~~
      |                        &
cc1plus: all warnings being treated as errors
make[2]: *** [src/CMakeFiles/elise.dir/build.make:3730: src/CMakeFiles/elise.dir/uti_image/NewRechPH/cOneScaleImRechPH.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:435: src/CMakeFiles/elise.dir/all] Error 2
make: *** [Makefile:136: all] Error 2
==> ERROR: A failure occurred in build().
    Aborting...
speters commented 2 years ago

The CMake Option -DWERROR=OFF mentioned in https://gist.github.com/muellerbernd/a41fb84f5d529ca8624a504187852376 makes it compile.

Additionally, the patch in https://github.com/micmacIGN/micmac/issues/166#issuecomment-842210506 is needed to successfully build an Arch package.

It finally worked with this: PKGBUILD cLoadedImage_template_fix.patch