根据网上的这个例子编译,却出现一些“undefined reference to”的错误;
错误如下:
8-3.cpp:(.text+0x81): undefined reference to `TiXmlDocument::TiXmlDocument(char const*)'
8-3.cpp:(.text+0x94): undefined reference to `TiXmlDocument::LoadFile(TiXmlEncoding)'
8-3.cpp:(.text+0x1a7): undefined reference to `TiXmlElement::GetText() const'
8-3.cpp:(.text+0x1f0): undefined reference to `TiXmlElement::Attribute(char const*) const'
/tmp/cceasJCM.o: In function `TiXmlNode::FirstChildElement()':
8-3.cpp:(.text._ZN9TiXmlNode17FirstChildElementEv[TiXmlNode::FirstChildElement()]+0xd): undefined reference to `TiXmlNode::FirstChildElement() const'
/tmp/cceasJCM.o: In function `TiXmlNode::FirstChild(char const*)':
8-3.cpp:(.text._ZN9TiXmlNode10FirstChildEPKc[TiXmlNode::FirstChild(char const*)]+0x14): undefined reference to `TiXmlNode::FirstChild(char const*) const'
/tmp/cceasJCM.o: In function `TiXmlNode::NextSibling(char const*)':
8-3.cpp:(.text._ZN9TiXmlNode11NextSiblingEPKc[TiXmlNode::NextSibling(char const*)]+0x14): undefined reference to `TiXmlNode::NextSibling(char const*) const'
/tmp/cceasJCM.o: In function `TiXmlString::quit()':
8-3.cpp:(.text._ZN11TiXmlString4quitEv[TiXmlString::quit()]+0xc): undefined reference to `TiXmlString::nullrep_'
/tmp/cceasJCM.o: In function `TiXmlDocument::~TiXmlDocument()':
8-3.cpp:(.text._ZN13TiXmlDocumentD1Ev[TiXmlDocument::~TiXmlDocument()]+0xb): undefined reference to `vtable for TiXmlDocument'
8-3.cpp:(.text._ZN13TiXmlDocumentD1Ev[TiXmlDocument::~TiXmlDocument()]+0x24): undefined reference to `TiXmlNode::~TiXmlNode()'
collect2: ld 返回 1
///
下面是要编译的测试程序
#include
#include "tinyxml.h"
using namespace std;
int main(int,char *[])
{
TiXmlDocument dom("D:/1.xml");
bool bSuccess = dom.LoadFile();
if (!bSuccess)
{
cout