When I'm trying to build a binary using pugi in wchar mode, I get a load of linker undefined reference errors hinting at the lack of wchar_t
versions of some functions in the library.
I'm using Ubuntu 16.04 and libpugixml-dev
that I got from apt-get.
Here's an example code that refuses to build:
#include <pugixml.hpp>
int main(int argc, char *argv[])
{
pugi::xml_node n;
n.set_name(L"");
return 0;
}
I build with
g++ -o pugi_test main.cpp -std=c++11 -DPUGIXML_WCHAR_MODE -lpugixml
and get
undefined reference to `pugi::xml_node::set_name(wchar_t const*)'
I also tried putting #define PUGIXML_WCHAR_MODE
in main.cpp
above #include
, and uncommenting the same #define
in pugiconfig.hpp
.
If I remove all traces of wchar (L""
⇒ ""
and remove -DPUGIXML_WCHAR_MODE
), build goes without a hitch.
Am I supposed to rebuild the library if I want to use wchar mode? I couldn't find anything of relevance in the manual.
Am I supposed to rebuild the library if I want to use wchar mode?
Yes. It would make little sense to have such PUGIXML_WCHAR_MODE
macro unless it controlled the compilation of the library (in my opinion). It must be (un-)defined both when compiling the library and the user of the library.