I'm attempting to use the pugiXML library to read some XML, and I can't get it to compile correctly. After moving the source files(3) into the working directory, bringing them into the project, and disabling the use of precompiled headers, I have been having a hard time trying to get it to link and build.
These are the snippets giving me problems:
// XMLAdapter.h
#pragma once
#include "pugixml.hpp"
using namespace pugi;
class XMLAdapter
{
private:
static xml_document doc;
static bool isReady;
static xml_parse_result result;
public:
static void setResource(char* resource);
template <typename T> static T getItems(char* xpath, T (*getThings)(xpath_node_set*));
};
.
// XMLAdapter.cpp
#include "stdafx.h"
#include "XMLAdapter.h"
bool XMLAdapter::isReady = false;
void XMLAdapter::setResource(char* resource){
XMLAdapter::result = XMLAdapter::doc.load_file(resource);
XMLAdapter::isReady = true;
}
and the errors:
- Error 1 error LNK2001: unresolved external symbol "private: static class pugi::xml_document XMLAdapter::doc" (?doc@XMLAdapter@@0Vxml_document@pugi@@A) C:\Users\Adam\SkyDrive\Documents\proj\ray\ray\XMLAdapter.obj ray
- Error 2 error LNK2001: unresolved external symbol "private: static struct pugi::xml_parse_result XMLAdapter::result" (?result@XMLAdapter@@0Uxml_parse_result@pugi@@A) C:\Users\Adam\SkyDrive\Documents\proj\ray\ray\XMLAdapter.obj ray
- Error 3 error LNK1120: 2 unresolved externals C:\Users\Adam\SkyDrive\Documents\proj\ray\Debug\ray.exe 1 1 ray
I'm fairly new to C++, so any advice would be welcome;