Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt undefined reference to `pugi::xml_document::xml_document()`

Tags:

c++

qt

pugixml

Recently I'm working on a project with Qt/C++/xml and some other stuff. I have to get some string values form a xml file. For that I'm using

#include "pugixml.hpp".

But when i'm using pugi::xml_document document; , it give an error as follow.

undefined reference to 'pugi::xml_document::xml_document()'

As I saw in this link I have to use pugixml.cpp while compiling. Anyone knows how to add pugixml.cpp to Qt project?

I'm using,

Qt Creator 4.0.2 Based on Qt 5.7.0 (GCC 4.9.1 20140922(Red Hat 4.9.1-10), 63 bit)

like image 562
Champika Avatar asked Jun 28 '26 06:06

Champika


1 Answers

You can fix this by editing the file called pugiconfig.hpp and uncommenting the line here:

// Uncomment this to switch to header-only version
//#define PUGIXML_HEADER_ONLY

Change it to:

// Uncomment this to switch to header-only version
#define PUGIXML_HEADER_ONLY

Now you don't need to include pugixml.cpp directly, the header will become self-contained.

like image 124
Galik Avatar answered Jun 29 '26 19:06

Galik