Ik probeer een library aan te spreken in een constructor-functie dmv
Dat levert volgende error:
configparser.o(.text+0x11c): In function `ConfigParser::ConfigParser[not-in-charge](std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/home/user01/Desktop/project/parser/configparser.C:18: undefined reference to `Dv::Util::Props::Props[in-charge](std::basic_istream<char, std::char_traits<char> >&)'
configparser.o(.text+0x12e):/home/user01/Desktop/project/parser/configparser.C:18: undefined reference to `Dv::Util::Props::~Props [in-charge]()'
configparser.o(.text+0x390): In function `ConfigParser::ConfigParser[in-charge](std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/home/user01/Desktop/project/parser/configparser.C:18: undefined reference to `Dv::Util::Props::Props[in-charge](std::basic_istream<char, std::char_traits<char> >&)'
configparser.o(.text+0x3a2):/home/user01/Desktop/project/parser/configparser.C:18: undefined reference to `Dv::Util::Props::~Props [in-charge]()'
configparser.o(.text+0x180):/home/user01/Desktop/project/parser/configparser.C:19: undefined reference to `Dv::Util::Props::operator[](std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
configparser.o(.text+0x18f):/home/user01/Desktop/project/parser/configparser.C:19: undefined reference to `Dv::Util::Props::Value::operator int() const'
collect2: ld returned 1 exit status
make: *** [shttpd] Fout 1
Het vlot niet echt met deze constructor dus
. Naar wat ik ervan begrijp wordt er dus geen passende functie gevonden die 'Util::Props config(ifs); ' kan invullen en dus ook geen goede operator[] of operator(). De library is volledig geinstalleerd. Ze bevat een constructor
Die leest lijntjes van de vorm 'key=value" uit een istream
Als voorbeeld bij deze lib kreeg ik onderstaande code mee (maar die werkt evenmin):
Iemand een idee waarom die Props-constructor niet wordt geactiveerd?
code:
1
2
3
4
5
6
7
8
| using namespace Dv;
ConfigParser::ConfigParser(const string& configspecs) throw (runtime_error): configfile_(configspecs){
ifstream ifs(configfile().c_str());
if (!ifs)
throw runtime_error(configfile() + " kon niet geopend worden");
Util::Props config(ifs);
_port = config("portnr");
} |
Dat levert volgende error:
configparser.o(.text+0x11c): In function `ConfigParser::ConfigParser[not-in-charge](std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/home/user01/Desktop/project/parser/configparser.C:18: undefined reference to `Dv::Util::Props::Props[in-charge](std::basic_istream<char, std::char_traits<char> >&)'
configparser.o(.text+0x12e):/home/user01/Desktop/project/parser/configparser.C:18: undefined reference to `Dv::Util::Props::~Props [in-charge]()'
configparser.o(.text+0x390): In function `ConfigParser::ConfigParser[in-charge](std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/home/user01/Desktop/project/parser/configparser.C:18: undefined reference to `Dv::Util::Props::Props[in-charge](std::basic_istream<char, std::char_traits<char> >&)'
configparser.o(.text+0x3a2):/home/user01/Desktop/project/parser/configparser.C:18: undefined reference to `Dv::Util::Props::~Props [in-charge]()'
configparser.o(.text+0x180):/home/user01/Desktop/project/parser/configparser.C:19: undefined reference to `Dv::Util::Props::operator[](std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
configparser.o(.text+0x18f):/home/user01/Desktop/project/parser/configparser.C:19: undefined reference to `Dv::Util::Props::Value::operator int() const'
collect2: ld returned 1 exit status
make: *** [shttpd] Fout 1
Het vlot niet echt met deze constructor dus
code:
1
| Dv::Util::Props::Props ( std::istream & is ) |
Die leest lijntjes van de vorm 'key=value" uit een istream
Als voorbeeld bij deze lib kreeg ik onderstaande code mee (maar die werkt evenmin):
code:
1
2
3
4
5
6
7
8
9
| ifstream ifs("/usr/local/share/z.config");
Props config(ifs);
try {
int max = config["max"];
}
catch (PropsException& e) {
cerr << "Configuration file does not define 'max'" << endl;
exit(1);
} |
Iemand een idee waarom die Props-constructor niet wordt geactiveerd?