XML parsing for I/O

Hi,
First of all i apologize in advance if this question wastes anybody’s time but i am a total newbie.
I need to parse an XML file and i am having issues using the TXMLEngine class in order to do that.

I am trying to use the code in this example (https://root.cern/doc/master/xmlreadfile_8C.html), but in compilation it gives the following errors:

/usr/bin/ld: /tmp/ccJiwqVU.o: in function `DisplayNode(TXMLEngine&, void*, int)':
main.cpp:(.text+0x170): undefined reference to `TXMLEngine::GetNodeName(void*)'
/usr/bin/ld: main.cpp:(.text+0x1a4): undefined reference to `TXMLEngine::GetNS(void*)'
/usr/bin/ld: main.cpp:(.text+0x1c2): undefined reference to `TXMLEngine::GetNSReference(void*)'
/usr/bin/ld: main.cpp:(.text+0x1d8): undefined reference to `TXMLEngine::GetNSName(void*)'
/usr/bin/ld: main.cpp:(.text+0x212): undefined reference to `TXMLEngine::GetFirstAttr(void*)'
/usr/bin/ld: main.cpp:(.text+0x230): undefined reference to `TXMLEngine::GetAttrValue(void*)'
/usr/bin/ld: main.cpp:(.text+0x246): undefined reference to `TXMLEngine::GetAttrName(void*)'
/usr/bin/ld: main.cpp:(.text+0x280): undefined reference to `TXMLEngine::GetNextAttr(void*)'
/usr/bin/ld: main.cpp:(.text+0x299): undefined reference to `TXMLEngine::GetNodeContent(void*)'
/usr/bin/ld: main.cpp:(.text+0x2df): undefined reference to `TXMLEngine::GetChild(void*, bool)'
/usr/bin/ld: main.cpp:(.text+0x31b): undefined reference to `TXMLEngine::GetNext(void*, bool)'
/usr/bin/ld: /tmp/ccJiwqVU.o: in function `xmlreadfile(char const*)':
main.cpp:(.text+0x355): undefined reference to `TXMLEngine::TXMLEngine()'
/usr/bin/ld: main.cpp:(.text+0x36d): undefined reference to `TXMLEngine::ParseFile(char const*, int)'
/usr/bin/ld: main.cpp:(.text+0x392): undefined reference to `TXMLEngine::DocGetRootElement(void*)'
/usr/bin/ld: main.cpp:(.text+0x3c1): undefined reference to `TXMLEngine::FreeDoc(void*)'
/usr/bin/ld: main.cpp:(.text+0x3d2): undefined reference to `TXMLEngine::~TXMLEngine()'
/usr/bin/ld: main.cpp:(.text+0x3f9): undefined reference to `TXMLEngine::~TXMLEngine()'
collect2: error: ld returned 1 exit status

The errors seem to tell that i am using the class TXMLEngine without having it included, but i did #include "TXMLEngine.h" so I should be able to use the class in my code.


Please read tips for efficient and successful posting and posting code

ROOT Version: 6.22
Platform: Ubuntu
Compiler: g++

Those are errors when linking the executable (that’s what /usr/bin/ld does). You did the correct thing with the #include in your source code. When linking your exeutable, you need to specify the library which contains the XML support, namely -lXMLIO.

1 Like