primer3-org / primer3

Primer3 is a command line tool to select primers for polymerase chain reaction (PCR).
GNU General Public License v2.0
223 stars 64 forks source link

Compiler error on Ubuntu 16.04 #6

Closed zamaudio closed 6 years ago

zamaudio commented 6 years ago
g++ -c -g -Wall -O2  -o libprimer3.o libprimer3.cc
In file included from /usr/include/c++/5/unordered_map:35:0,
                 from libprimer3.cc:48:
/usr/include/c++/5/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
 #error This file requires compiler and library support \
  ^
libprimer3.cc:52:19: error: '__gnu_cxx' is not a namespace-name
   using namespace __gnu_cxx;
                   ^
libprimer3.cc:52:28: error: expected namespace-name before ';' token
   using namespace __gnu_cxx;
                            ^
libprimer3.cc:129:13: error: 'unordered_map' in namespace 'std' does not name a template type
 static std::unordered_map<int, primer_pair*> **pairs;
             ^
libprimer3.cc: In function 'void free_pair_memory(int)':
libprimer3.cc:1124:3: error: 'unordered_map' is not a member of 'std'
   std::unordered_map<int, primer_pair*> *hmap;
   ^
libprimer3.cc:1124:22: error: expected primary-expression before 'int'
   std::unordered_map<int, primer_pair*> *hmap;
                      ^
libprimer3.cc:1125:3: error: 'unordered_map' is not a member of 'std'
   std::unordered_map<int, primer_pair*>::iterator it;
   ^
libprimer3.cc:1125:22: error: expected primary-expression before 'int'
   std::unordered_map<int, primer_pair*>::iterator it;
                      ^
libprimer3.cc:1131:5: error: 'hmap' was not declared in this scope
     hmap = pairs[i];
     ^
libprimer3.cc:1131:12: error: 'pairs' was not declared in this scope
     hmap = pairs[i];
            ^
libprimer3.cc:1133:12: error: 'it' was not declared in this scope
       for (it=hmap->begin(); it!=hmap->end(); it++) {
            ^
libprimer3.cc:1138:14: error: type '<type error>' argument given to 'delete', expected pointer
       delete hmap;
              ^
libprimer3.cc:1141:8: error: 'pairs' was not declared in this scope
   free(pairs);
        ^
libprimer3.cc: In function 'void choose_pair_or_triple(p3retval*, const p3_global_settings*, const seq_args*, const dpal_arg_holder*, const thal_arg_holder*, const thal_arg_holder*, pair_array_t*)':
libprimer3.cc:1352:3: error: 'unordered_map' is not a member of 'std'
   std::unordered_map<int, primer_pair*> *hmap, *best_hmap = NULL;
   ^
libprimer3.cc:1352:22: error: expected primary-expression before 'int'
   std::unordered_map<int, primer_pair*> *hmap, *best_hmap = NULL;
                      ^
libprimer3.cc:1356:3: error: 'unordered_map' is not a member of 'std'
   std::unordered_map<int, primer_pair*>::iterator it;
   ^
libprimer3.cc:1356:22: error: expected primary-expression before 'int'
   std::unordered_map<int, primer_pair*>::iterator it;
                      ^
libprimer3.cc:1360:3: error: 'pairs' was not declared in this scope
   pairs =
   ^
libprimer3.cc:1361:6: error: 'unordered_map' is not a member of 'std'
     (std::unordered_map<int, primer_pair*>**) 
      ^
libprimer3.cc:1361:25: error: expected primary-expression before 'int'
     (std::unordered_map<int, primer_pair*>**) 
                         ^
libprimer3.cc:1361:25: error: expected ')' before 'int'
libprimer3.cc:1384:7: error: 'hmap' was not declared in this scope
       hmap = pairs[i];  
       ^
libprimer3.cc:1398:16: error: 'it' was not declared in this scope
           for (it=hmap->begin(); it!=hmap->end(); it++) {
                ^
libprimer3.cc:1404:16: error: 'best_hmap' was not declared in this scope
    if (hmap == best_hmap) best_hmap = NULL;
                ^
libprimer3.cc:1405:18: error: type '<type error>' argument given to 'delete', expected pointer
           delete hmap;
                  ^
libprimer3.cc:1434:16: error: 'it' was not declared in this scope
           for (it=hmap->begin(); it!=hmap->end(); it++) {
                ^
libprimer3.cc:1440:16: error: 'best_hmap' was not declared in this scope
    if (hmap == best_hmap) best_hmap = NULL;
                ^
libprimer3.cc:1441:18: error: type '<type error>' argument given to 'delete', expected pointer
           delete hmap;
                  ^
libprimer3.cc:1457:18: error: 'it' was not declared in this scope
             for (it=hmap->begin(); it!=hmap->end(); it++) {
                  ^
libprimer3.cc:1463:18: error: 'best_hmap' was not declared in this scope
      if (hmap == best_hmap) best_hmap = NULL;
                  ^
libprimer3.cc:1464:13: error: type '<type error>' argument given to 'delete', expected pointer
      delete hmap;
             ^
libprimer3.cc:1554:11: error: 'it' was not declared in this scope
           it = hmap->find(j);
           ^
libprimer3.cc:1575:3: error: 'best_hmap' was not declared in this scope
   best_hmap = hmap;
   ^
libprimer3.cc:1587:27: error: 'unordered_map' in namespace 'std' does not name a template type
           hmap = new std::unordered_map<int, primer_pair*>;
                           ^
libprimer3.cc:1587:41: error: expected primary-expression before 'int'
           hmap = new std::unordered_map<int, primer_pair*>;
                                         ^
libprimer3.cc:1650:15: error: 'best_hmap' was not declared in this scope
               best_hmap = hmap;
               ^
libprimer3.cc:1704:9: error: 'best_hmap' was not declared in this scope
       (*best_hmap)[the_best_j] = NULL;
         ^
make: *** [libprimer3.o] Error 1
Makefile:168: recipe for target 'libprimer3.o' failed
zamaudio commented 6 years ago

I developed this on fedora 27 - it works fine there - but on ubuntu it chokes... I didn't realise unordered_map was a C++11 ism.

@untergasser is it going to be a problem to enforce -std=c++11 on this project for libprimer3.cc ?

zamaudio commented 6 years ago

If you don't want to have the dependency on C++11 standards, I can provide a revert patch to revert the unordered_map change if you prefer. Otherwise we can just add a compile flag to move forward.

zamaudio commented 6 years ago

The above patch just adds the compile flag -std=c++11 instead of rolling back to a deprecated api.