Question

I'm writing a static library that uses PugiXml for xml parsing. Here is the linker output from Visual Studio 2010 (I've replaced the symbol with ellipses for readability):

error LNK2019: unresolved external symbol "public: __thiscall Dae_Library<class Dae_Geometry>::Dae_Library<class Dae_Geometry>(void)" (...) referenced in function "private: bool __thiscall Dae_Doc::ParseDae(void)" (...)
error LNK2019: ^ "public: wchar_t const * __thiscall pugi::xml_node::name(void)const " (...) referenced in function "private: bool __thiscall Dae_Doc::ParseDae(void)" (...)
error LNK2001: ^ "public: wchar_t const * __thiscall pugi::xml_node::name(void)const " (...)
error LNK2019: ^ "public: wchar_t const * __thiscall pugi::xml_attribute::value(void)const " (...) referenced in function "public: void __thiscall Dae_Node::SetXmlNode(class pugi::xml_node &)" (...)
error LNK2019: ^ "public: class pugi::xml_attribute __thiscall pugi::xml_node::attribute(wchar_t const *)const " (...) referenced in function "public: void __thiscall Dae_Node::SetXmlNode(class pugi::xml_node &)" (...)

Things I've tried:

  • Explicitly instantiating my template class.
  • Linking PugiXml source in with test project (it is currently with the static lib I'm building)
  • Building PugiXml as a static lib and referencing it in both my lib project and the test project
  • Writing do nothing functions in place of my pure virtual functions.
  • Providing default constructors that do not reference pugixml at all

This has been driving me nuts for the past two days and I really have no idea what to do. If anyone can give me any direction at all I would greatly appreciate it!

Edit: It's worth noting that creating a simple static library that uses pugixml compiles and tests fine, so maybe there is something wrong with how I've written my templates and classes?

Was it helpful?

Solution

From the error messages it looks like you're setting PUGIXML_WCHAR_MODE inconsistently.

It's likely that you're setting it in your project configuration, and using one of the bundled vcproj files from scripts/ folder inside pugixml distribution as is.

This define controls the type of character used in pugixml (char or wchar_t); you have to set it in the same way for both pugixml.cpp and the code that uses pugixml - it is recommended to either set it in pugiconfig.hpp, or to make sure that it's on in all projects that have source files that include pugixml.hpp. In your case, if you don't want to modify pugiconfig.hpp, you'll have to change the vcproj for pugixml static library.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top