Ich brauche Hilfe auf, ich habe dies auf dem gleichen Computer getan, es bedeutet, ich habe bereits Boost-Bibliothek installiert und basiert auf dem vorherigen Code, aber dieses Mal gibt es mir Fehler: /tmp/ccpAYzPw.o: In Funktion `Haupt ':Was ist falsch an <boost/program_options/options_description.hpp>?
reading_data.cpp:(.text+0x356): undefined reference to `boost::program_options::options_description::m_default_line_length'
reading_data.cpp:(.text+0x361): undefined reference to `boost::program_options::options_description::m_default_line_length'
reading_data.cpp:(.text+0x3a6): undefined reference to `boost::program_options::options_description::options_description(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned int, unsigned int)'
reading_data.cpp:(.text+0x3d3): undefined reference to `boost::program_options::options_description::add_options()'
collect2: error: ld returned 1 exit status
<builtin>: recipe for target 'reading_data' failed
Ich verbrachte fast 2 Stunden, um zu sehen, was vor sich geht? aber ich konnte nicht verstehen warum, also brauche ich deine Hilfe.
Hier ist mein Code und ich danke Ihnen sehr.
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <fstream> // std::ifstream
#include <boost/program_options.hpp>
int main()
{
boost::program_options::options_description desc("Allowed options");
desc.add_options()
("sign" , program_options::value<string>() -> default_value("gbm") ,"name of the input")
("week" , program_options::value<double>() -> default_value(1930) ,"number of the week")
("day" , program_options::value<double>() -> default_value(0) ,"number of the day in within the week")
("hour" , program_options::value<double>() -> default_value(0) ,"time in hour")
("minute", program_options::value<double>() -> default_value(0) ,"time in minute")
("second", program_options::value<double>() -> default_value(0) ,"time in second")
;
cout << "Done!" << endl;
return 0;
}
Es sieht aus wie Sie nicht die Boost program_options Bibliothek verknüpft sind. – roalz
Ich denke, das Semikolon am Ende von 'desc.add_options();' ist ein Problem für später. – Quentin
** Keine Spam-Tags. ** Diese Frage hat nichts mit "c" oder "Informatik" zu tun. –