Francesco S. Carta wrote:
On 3 Ott, 17:05, davee <da...@nomail.com> wrote:
I am trying to use the code posted here:
http://www.senzee5.com/2008/02/java-style-properties-files-in-c.html
I use it like this:
#include "propertyutil.h"
int main(){
PropertyUtil properties;
typedef PropertyUtil::PropertyMapT MapType;
MapType bob;
properties.read(config_path.c_str(), bob);
return 0;
}
but I get the error:
main.cpp:(.text+0xc29): undefined reference to `PropertyUtil::read(char
const*, std::map<std::basic_string<char, std::char_traits<char>,
std::allocator<char> >, std::basic_string<char, std::char_traits<char>,
std::allocator<char> >, std::less<std::basic_string<char,
std::char_traits<char>, std::allocator<char> > >,
std::allocator<std::pair<std::basic_string<char, std::char_traits<char>,
std::allocator<char> > const, std::basic_string<char,
std::char_traits<char>, std::allocator<char> > > > >&)'
'read' is:
class PropertyUtil {
enum { DEBUG = 0 };
public:
typedef std::map<std::string, std::string> PropertyMapT;
typedef PropertyMapT::value_type value_type;
typedef PropertyMapT::iterator iterator;
static void read(const char *filename, PropertyMapT &map);
..
..
What am I doing wrong here?
An error telling "undefined reference to [whatever]" comes from the
linker. It means that no available compilation unit defined that thing
- it is just _declared_, in that header.
In this very case, find out what library you need, download it and add
it to your linker references.
When you get the same kind of errors with your very names, that would
mean that you forgot to define those names (that is, you just declared
them, as it happened above).
Have good time,
Francesco
--
Francesco S. Carta, hobbyist
http://fscode.altervista.org
in the end of the propertyutil.h file, seems a bit wierd though. But