brainvisa/soma-io

Compilation error with gcc 13.1.0 from conda-forge

Closed this issue · 1 comments

I recently noticed the following errors when trying a compile using Conda. I did not check yet the appropriate solution. I could be either to fix the code or to use a different gcc version (of course I am a priori in favour of the first solution):

In file included from /home/yann/dev/casaconda/src/soma-io/src/somamif/image/mifimagereader.cc:35:
/home/yann/dev/casaconda/build/include/soma-io/image/mifimagereader_d.h: In function 'std::vector<long unsigned int> {anonymous}::argsort_abs(const SequenceT&)':
/home/yann/dev/casaconda/build/include/soma-io/image/mifimagereader_d.h:334:44: error: use of 'auto' in lambda parameter declaration only available with '-std=c++14' or '-std=gnu++14'
  334 |   std::sort(begin(ret), end(ret), [values](auto a, auto b) -> bool {
      |                                            ^~~~
/home/yann/dev/casaconda/build/include/soma-io/image/mifimagereader_d.h:334:52: error: use of 'auto' in lambda parameter declaration only available with '-std=c++14' or '-std=gnu++14'
  334 |   std::sort(begin(ret), end(ret), [values](auto a, auto b) -> bool {
      |                                                    ^~~~
/home/yann/dev/casaconda/build/include/soma-io/image/mifimagereader_d.h: In member function 'void carto::MifImageReader<T>::readType(T*, carto::DataSourceInfo&, std::vector<int>&, std::vector<int>&, std::vector<long int>&, carto::Object)':
/home/yann/dev/casaconda/build/include/soma-io/image/mifimagereader_d.h:470:75: error: use of 'auto' in lambda parameter declaration only available with '-std=c++14' or '-std=gnu++14'
  470 |     std::size_t dest_size = std::accumulate(begin(size), end(size), 1, [](auto a, auto b) { return a*b; });
      |                                                                           ^~~~
/home/yann/dev/casaconda/build/include/soma-io/image/mifimagereader_d.h:470:83: error: use of 'auto' in lambda parameter declaration only available with '-std=c++14' or '-std=gnu++14'
  470 |     std::size_t dest_size = std::accumulate(begin(size), end(size), 1, [](auto a, auto b) { return a*b; });
      |                                                                                   ^~~~
/home/yann/dev/casaconda/build/include/soma-io/image/mifimagereader_d.h: In member function 'void carto::MifImageReader<T>::readBitwise(uint8_t*, carto::DataSourceInfo&, std::vector<int>&, std::vector<int>&, std::vector<long int>&, carto::Object)':
/home/yann/dev/casaconda/build/include/soma-io/image/mifimagereader_d.h:589:75: error: use of 'auto' in lambda parameter declaration only available with '-std=c++14' or '-std=gnu++14'
  589 |     std::size_t dest_size = std::accumulate(begin(size), end(size), 1, [](auto a, auto b) { return a*b; });
      |                                                                           ^~~~
/home/yann/dev/casaconda/build/include/soma-io/image/mifimagereader_d.h:589:83: error: use of 'auto' in lambda parameter declaration only available with '-std=c++14' or '-std=gnu++14'
  589 |     std::size_t dest_size = std::accumulate(begin(size), end(size), 1, [](auto a, auto b) { return a*b; });
      |                                                                                   ^~~~
make[2]: *** [build_files/soma-io/src/somamif/CMakeFiles/somamif.dir/build.make:90 : build_files/soma-io/src/somamif/CMakeFiles/somamif.dir/image/mifimagereader.cc.o] Erreur 1
[ 91%] Building CXX object build_files/aims-free/aimsdata/src/aimsdata/CMakeFiles/aimsdata.dir/io/reader_motion.cc.o
In file included from /home/yann/dev/casaconda/src/aims-free/aimsdata/src/aimsdata/io/fileFormat_volume.cc:49:
/home/yann/dev/casaconda/build/include/aims/io/fileFormat_cartovolume_d.h: In member function 'virtual carto::VolumeRef<T>* aims::VolumeRefAimsFormat<T>::read(const std::string&, const carto::AllocatorContext&, carto::Object)':
/home/yann/dev/casaconda/build/include/aims/io/fileFormat_cartovolume_d.h:272:36: error: expected type-specifier
  272 |     carto::VolumeRef<T> *vol = new carto::VolumeRef( r.read() );
      |                                    ^~~~~
/home/yann/dev/casaconda/src/soma-io/src/somamif/checker/mifformatchecker.cc:195:42: error: 'unordered_map' does not name a type
  195 | string get_unique_mif_header_field(const unordered_map<string, vector<string>> &raw_header,
      |                                          ^~~~~~~~~~~~~
/home/yann/dev/casaconda/src/soma-io/src/somamif/checker/mifformatchecker.cc:195:55: error: expected ',' or '...' before '<' token
  195 | string get_unique_mif_header_field(const unordered_map<string, vector<string>> &raw_header,
      |                                                       ^
In file included from /home/yann/dev/casaconda/src/aims-free/aimsdata/src/aimsdata/io/fileFormat_volumeVec.cc:50:
/home/yann/dev/casaconda/build/include/aims/io/fileFormat_cartovolume_d.h: In member function 'virtual carto::VolumeRef<T>* aims::VolumeRefAimsFormat<T>::read(const std::string&, const carto::AllocatorContext&, carto::Object)':
/home/yann/dev/casaconda/build/include/aims/io/fileFormat_cartovolume_d.h:272:36: error: expected type-specifier
  272 |     carto::VolumeRef<T> *vol = new carto::VolumeRef( r.read() );
      |                                    ^~~~~
/home/yann/dev/casaconda/src/soma-io/src/somamif/checker/mifformatchecker.cc: In function 'std::string {anonymous}::get_unique_mif_header_field(int)':
/home/yann/dev/casaconda/src/soma-io/src/somamif/checker/mifformatchecker.cc:198:20: error: 'raw_header' was not declared in this scope; did you mean 'gz_header'?
  198 |   auto header_it = raw_header.find(field_name);
      |                    ^~~~~~~~~~
      |                    gz_header
/home/yann/dev/casaconda/src/soma-io/src/somamif/checker/mifformatchecker.cc:198:36: error: 'field_name' was not declared in this scope
  198 |   auto header_it = raw_header.find(field_name);
      |                                    ^~~~~~~~~~
/home/yann/dev/casaconda/src/soma-io/src/somamif/checker/mifformatchecker.cc:201:33: error: 'filename' was not declared in this scope; did you mean 'rename'?
  201 |                                 filename );
      |                                 ^~~~~~~~
      |                                 rename
/home/yann/dev/casaconda/src/soma-io/src/somamif/checker/mifformatchecker.cc:205:33: error: 'filename' was not declared in this scope; did you mean 'rename'?
  205 |                                 filename );
      |                                 ^~~~~~~~
      |                                 rename
/home/yann/dev/casaconda/src/soma-io/src/somamif/checker/mifformatchecker.cc: At global scope:
/home/yann/dev/casaconda/src/soma-io/src/somamif/checker/mifformatchecker.cc:242:51: error: 'unordered_map' does not name a type
  242 | vector<Element> parse_comma_separated_field(const unordered_map<string, vector<string>> &raw_header,
      |                                                   ^~~~~~~~~~~~~
/home/yann/dev/casaconda/src/soma-io/src/somamif/checker/mifformatchecker.cc:242:64: error: expected ',' or '...' before '<' token
  242 | vector<Element> parse_comma_separated_field(const unordered_map<string, vector<string>> &raw_header,
      |                                                                ^
/home/yann/dev/casaconda/src/soma-io/src/somamif/checker/mifformatchecker.cc: In function 'std::vector<T> {anonymous}::parse_comma_separated_field(int)':
/home/yann/dev/casaconda/src/soma-io/src/somamif/checker/mifformatchecker.cc:245:50: error: 'raw_header' was not declared in this scope; did you mean 'gz_header'?
  245 |   string raw_value = get_unique_mif_header_field(raw_header, field_name, filename);
      |                                                  ^~~~~~~~~~
      |                                                  gz_header
/home/yann/dev/casaconda/src/soma-io/src/somamif/checker/mifformatchecker.cc:245:62: error: 'field_name' was not declared in this scope
  245 |   string raw_value = get_unique_mif_header_field(raw_header, field_name, filename);
      |                                                              ^~~~~~~~~~
/home/yann/dev/casaconda/src/soma-io/src/somamif/checker/mifformatchecker.cc:245:74: error: 'filename' was not declared in this scope; did you mean 'rename'?
  245 |   string raw_value = get_unique_mif_header_field(raw_header, field_name, filename);
      |                                                                          ^~~~~~~~
      |                                                                          rename
/home/yann/dev/casaconda/src/soma-io/src/somamif/checker/mifformatchecker.cc: In member function 'carto::Object carto::MifFormatChecker::_buildHeader(carto::DataSource&) const':
/home/yann/dev/casaconda/src/soma-io/src/somamif/checker/mifformatchecker.cc:309:3: error: 'unordered_map' was not declared in this scope
  309 |   unordered_map<string, vector<string>> raw_header;
      |   ^~~~~~~~~~~~~
/home/yann/dev/casaconda/src/soma-io/src/somamif/checker/mifformatchecker.cc:59:1: note: 'std::unordered_map' is defined in header '<unordered_map>'; did you forget to '#include <unordered_map>'?
   58 | #include <cartobase/config/verbose.h>
  +++ |+#include <unordered_map>
   59 | #define localMsg( message ) cartoCondMsg( 4, message, "MIFFORMATCHECKER" )
/home/yann/dev/casaconda/src/soma-io/src/somamif/checker/mifformatchecker.cc:309:23: error: expected primary-expression before ',' token
  309 |   unordered_map<string, vector<string>> raw_header;
      |                       ^
/home/yann/dev/casaconda/src/soma-io/src/somamif/checker/mifformatchecker.cc:309:38: error: expected primary-expression before '>' token
  309 |   unordered_map<string, vector<string>> raw_header;
      |                                      ^~
/home/yann/dev/casaconda/src/soma-io/src/somamif/checker/mifformatchecker.cc:309:41: error: 'raw_header' was not declared in this scope; did you mean 'gz_header'?
  309 |   unordered_map<string, vector<string>> raw_header;
      |                                         ^~~~~~~~~~
      |                                         gz_header
/home/yann/dev/casaconda/src/soma-io/src/somamif/checker/mifformatchecker.cc:353:32: error: 'rbegin' was not declared in this scope; did you mean 'boost::rbegin'?
  353 |   auto last_space_it = find_if(rbegin(file_and_offset), rend(file_and_offset),
      |                                ^~~~~~
      |                                boost::rbegin
In file included from /home/yann/dev/casaconda/conda/include/boost/range/functions.hpp:23,
                 from /home/yann/dev/casaconda/conda/include/boost/range/iterator_range_core.hpp:38,
                 from /home/yann/dev/casaconda/conda/include/boost/range/iterator_range.hpp:13,
                 from /home/yann/dev/casaconda/conda/include/boost/range/as_literal.hpp:18,
                 from /home/yann/dev/casaconda/conda/include/boost/algorithm/string/trim.hpp:19,
                 from /home/yann/dev/casaconda/conda/include/boost/algorithm/string.hpp:19,
                 from /home/yann/dev/casaconda/src/soma-io/src/somamif/checker/mifformatchecker.cc:56:
/home/yann/dev/casaconda/conda/include/boost/range/rbegin.hpp:35:1: note: 'boost::rbegin' declared here
   35 | rbegin( const C& c )
      | ^~~~~~
/home/yann/dev/casaconda/src/soma-io/src/somamif/checker/mifformatchecker.cc:353:57: error: 'rend' was not declared in this scope; did you mean 'boost::rend'?
  353 |   auto last_space_it = find_if(rbegin(file_and_offset), rend(file_and_offset),
      |                                                         ^~~~
      |                                                         boost::rend
In file included from /home/yann/dev/casaconda/conda/include/boost/range/functions.hpp:24:
/home/yann/dev/casaconda/conda/include/boost/range/rend.hpp:35:1: note: 'boost::rend' declared here
   35 | rend( const C& c )
      | ^~~~
make[2]: *** [build_files/soma-io/src/somamif/CMakeFiles/somamif.dir/build.make:76 : build_files/soma-io/src/somamif/CMakeFiles/somamif.dir/checker/mifformatchecker.cc.o] Erreur 1
make[2]: La cible « build_files/soma-io/src/somamif/CMakeFiles/somamif.dir/build » n'a pas été refabriquée à cause d'erreurs.

Following @denisri advice, I had a look into distribution specific CMake code in brainvisa-cmake project. The two following lines are defined specifically for Ubuntu 22.04:

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

Including them to conda.cmake solves the problem. Therefore I will close this issue and open one in brainvisa-cmake to discuss the good way to resolve the issue.