bioinformatics-centre / kaiju

Fast taxonomic classification of metagenomic sequencing reads using a protein reference database
http://kaiju.binf.ku.dk
GNU General Public License v3.0
260 stars 68 forks source link

Compile error #19

Closed koopkaup closed 7 years ago

koopkaup commented 7 years ago

I get this error when compiling the newest version on Kaiju (using gcc version 5.2.0):

kaiju2krona.cpp: In function ‘int main(int, char**)’:
kaiju2krona.cpp:37:47: error: ‘getopt’ was not declared in this scope
  while ((c = getopt (argc, argv, "huvn:t:i:o:")) != -1) {
                                               ^
make: *** [kaiju2krona.o] Error 1
pmenzel commented 7 years ago

Please try to add the line

#include <unistd.h>

to the beginning of kaiju2krona.cpp and see if it compiles.

koopkaup commented 7 years ago

Yes, this compiles now, but I have a new error with kaijuReport.cpp

kaijuReport.cpp: In function ‘int main(int, char**)’:
kaijuReport.cpp:239:35: error: expected ‘)’ before ‘PRIu64’
   fprintf(report_file,"%9.6f\t%9" PRIu64 "\t%s\n", percent, it.first, name.c_str() );
                                   ^
kaijuReport.cpp:239:84: warning: conversion lacks type at end of format [-Wformat=]
   fprintf(report_file,"%9.6f\t%9" PRIu64 "\t%s\n", percent, it.first, name.c_str() );
                                                                                    ^
kaijuReport.cpp:239:84: warning: too many arguments for format [-Wformat-extra-args]
kaijuReport.cpp:243:34: error: expected ‘)’ before ‘PRIu64’
  fprintf(report_file,"%9.6f\t%9" PRIu64 "\tViruses\n", (float)viruses/(float)totalreads*100.0, viruses);
                                  ^
kaijuReport.cpp:243:103: warning: conversion lacks type at end of format [-Wformat=]
  fprintf(report_file,"%9.6f\t%9" PRIu64 "\tViruses\n", (float)viruses/(float)totalreads*100.0, viruses);
                                                                                                       ^
kaijuReport.cpp:243:103: warning: too many arguments for format [-Wformat-extra-args]
kaijuReport.cpp:244:34: error: expected ‘)’ before ‘PRIu64’
  fprintf(report_file,"%9.6f\t%9" PRIu64 "\tclassified above rank %s \n", (float)above/(float)totalreads*100.0, above, rank.c_str());
                                  ^
kaijuReport.cpp:244:131: warning: conversion lacks type at end of format [-Wformat=]
  fprintf(report_file,"%9.6f\t%9" PRIu64 "\tclassified above rank %s \n", (float)above/(float)totalreads*100.0, above, rank.c_str());
                                                                                                                                   ^
kaijuReport.cpp:244:131: warning: too many arguments for format [-Wformat-extra-args]
kaijuReport.cpp:246:35: error: expected ‘)’ before ‘PRIu64’
   fprintf(report_file,"%9.6f\t%9" PRIu64 "\tbelong to a %s having less than %i reads\n", (float)below_reads/(float)totalreads*100.0, below_reads, rank.c_str(), min_read_count);
                                   ^
kaijuReport.cpp:246:175: warning: conversion lacks type at end of format [-Wformat=]
   fprintf(report_file,"%9.6f\t%9" PRIu64 "\tbelong to a %s having less than %i reads\n", (float)below_reads/(float)totalreads*100.0, below_reads, rank.c_str(), min_read_count);
                                                                                                                                                                               ^
kaijuReport.cpp:246:175: warning: too many arguments for format [-Wformat-extra-args]
kaijuReport.cpp:248:35: error: expected ‘)’ before ‘PRIu64’
   fprintf(report_file,"%9.6f\t%9" PRIu64 "\tbelong to a %s with less than %g%% of all reads\n", (float)below_percent/(float)totalreads*100.0, below_percent, rank.c_str(), min_percent);
                                   ^
kaijuReport.cpp:248:183: warning: conversion lacks type at end of format [-Wformat=]
   fprintf(report_file,"%9.6f\t%9" PRIu64 "\tbelong to a %s with less than %g%% of all reads\n", (float)below_percent/(float)totalreads*100.0, below_percent, rank.c_str(), min_percent);
                                                                                                                                                                                       ^
kaijuReport.cpp:248:183: warning: too many arguments for format [-Wformat-extra-args]
kaijuReport.cpp:251:35: error: expected ‘)’ before ‘PRIu64’
   fprintf(report_file,"%9.6f\t%9" PRIu64 "\tunclassified\n", (float)unclassified/(float)(totalreads+unclassified)*100.0, unclassified );
                                   ^
kaijuReport.cpp:251:135: warning: conversion lacks type at end of format [-Wformat=]
   fprintf(report_file,"%9.6f\t%9" PRIu64 "\tunclassified\n", (float)unclassified/(float)(totalreads+unclassified)*100.0, unclassified );
                                                                                                                                       ^
kaijuReport.cpp:251:135: warning: too many arguments for format [-Wformat-extra-args]
kaijuReport.cpp:253:35: error: expected ‘)’ before ‘PRIu64’
   fprintf(report_file,"%9.6f\t%9" PRIu64 "\tunclassified\n", (float)unclassified/(float)(totalreads)*100.0, unclassified );
                                   ^
kaijuReport.cpp:253:122: warning: conversion lacks type at end of format [-Wformat=]
   fprintf(report_file,"%9.6f\t%9" PRIu64 "\tunclassified\n", (float)unclassified/(float)(totalreads)*100.0, unclassified );
                                                                                                                          ^
kaijuReport.cpp:253:122: warning: too many arguments for format [-Wformat-extra-args]
make: *** [kaijuReport.o] Error 1
pmenzel commented 7 years ago

Interesting, never got this error. The solution according to this stackoverflow post would be to add the line

#define __STDC_FORMAT_MACROS

before the line

#include <inttypes.h> 

at the beginning of kaijuReport.cpp. Could you try it out? Then I can make a commit. thanks.

koopkaup commented 7 years ago

This worked. Thank you!

pmenzel commented 7 years ago

Great, thanks for helping!