DerrickWood / kraken2

The second version of the Kraken taxonomic sequence classification system
MIT License
718 stars 270 forks source link

'SIZE_MAX' was not declared in this scope & 'UINT64_MAX' was not declared in this scope #29

Closed shyamrallapalli closed 6 years ago

shyamrallapalli commented 6 years ago

my linux distribution is CentOS release 6.7 (Final) compiled kraken2 with gcc-4.9.3

g++ -fopenmp -Wall -std=c++11 -O3 -DLINEAR_PROBING   -c -o mmscanner.o mmscanner.cc
In file included from mmscanner.cc:7:0:
mmscanner.h:34:23: error: 'SIZE_MAX' was not declared in this scope
       size_t finish = SIZE_MAX);
                       ^
mmscanner.cc: In constructor 'kraken2::MinimizerScanner::MinimizerScanner(ssize_t, ssize_t, uint64_t, bool, uint64_t)':
mmscanner.cc:32:18: error: 'SIZE_MAX' was not declared in this scope
   if (finish_ == SIZE_MAX)
                  ^
mmscanner.cc: In member function 'void kraken2::MinimizerScanner::LoadSequence(std::string&, size_t, size_t)':
mmscanner.cc:43:18: error: 'SIZE_MAX' was not declared in this scope
   if (finish_ == SIZE_MAX)
                  ^
make: *** [mmscanner.o] Error 1

fixed it based on suggestion in the following post https://stackoverflow.com/a/42097570

That lead to next issue

g++ -fopenmp -Wall -std=c++11 -O3 -DLINEAR_PROBING    classify.cc reports.o mmap_file.o compact_hash.o taxonomy.o seqreader.o mmscanner.o omp_hack.o aa_translate.o   -o classify
classify.cc: In function 'taxid_t ClassifySequence(kraken2::Sequence&, kraken2::Sequence&, std::ostringstream&, kraken2::KeyValueStore*, kraken2::Taxonomy&, IndexOptions&, Options&, ClassificationStats&, kraken2::MinimizerScanner&, std::vector<long unsigned int>&, taxon_counts_t&, std::vector<std::basic_string<char> >&)':
classify.cc:505:33: error: 'UINT64_MAX' was not declared in this scope
       uint64_t last_minimizer = UINT64_MAX;
                                 ^
make: *** [classify] Error 1

fixed it based on the suggestion from following post https://stackoverflow.com/a/3233069

posting the patch here as a solution for any one facing this issue fix_install_kraken2.patch.txt

DerrickWood commented 6 years ago

Hi, this appears to be due to older glibc implementations demanding the use of STDC_LIMIT_MACROS and STDC_CONSTANT_MACROS to get those values defined. That behavior was appropriate for C99, but is non-standard for C++11 (see https://sourceware.org/bugzilla/show_bug.cgi?id=15366).

I don't have access to an old implementation of glibc; if the following code is added to the end of kraken2_headers.h, would that solve your compilation problems? If so, I think that's a fix I can easily commit.

#ifndef SIZE_MAX
#define SIZE_MAX ((size_t) -1)
#endif

#ifndef UINT64_MAX
#define UINT64_MAX ((uint64_t) -1)
#endif
shyamrallapalli commented 6 years ago

Hi @DerrickWood , yes that fixes it here is my glibc version for record

ldd --version
ldd (GNU libc) 2.12
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.
DerrickWood commented 6 years ago

OK, I've added the definition of those constants in https://github.com/DerrickWood/kraken2/commit/1bad13827d9c5d81337cc6ea53ec33ace389db4a, should help others similarly situated to you.