#134 Linker error when using streaming operator for ticpp::Document

open
nobody
None
5
2014-05-12
2014-05-12
Danjo
No

Get linker error when trying to use streaming operators with ticpp::Document. Attaching an patch to resolve the issue.

What steps will reproduce the problem?
Try to read in a ticpp::Document using std::istream using:

#include <ticpp/ticpp.h>
#include <fstream>
using namespace std;

int main() {
ifstream stream(fileName);
ticpp::Document doc;
stream >> doc;
return 0;
}
What is the expected output? What do you see instead?
The application does not link:
Error 1 error LNK2019: unresolved external symbol "class std::basic_istream<char,struct std::char_traits<char=""> > & cdecl operator>>(class std::basic_istream<char,struct std::char_traits<char=""> > &,class TiXmlNode &)" (??5@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@std@@AEAV01@AEAVTiXmlNode@@@Z) referenced in function "class std::basic_istream<char,struct std::char_traits<char=""> > & cdecl ticpp::operator>>(class std::basic_istream<char,struct std::char_traits<char=""> > &,class ticpp::Node &)" (??5ticpp@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@std@@AEAV12@AEAVNode@0@@Z)

Tested in Visual Studio 2012.

See this for an explanation of why it happens:
http://stackoverflow.com/questions/15430665/unresolved-external-symbol-for-friend-function

Attached patch that moves the namespace declaration in the ticpp.cpp file.

1 Attachments

Discussion

  • Danjo
    Danjo
    2014-05-12

    After further testing it turned out that adding the namespaces was not enough. Moving the implementation of the streaming operators fixed the problem though. Attaching new patch to resolve the problem.

     
    Last edit: Danjo 2014-05-12
    Attachments