You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Samantha Savvakis <sa...@cfs.net.au> on 2002/05/14 04:35:24 UTC

Off Topic - gmake code undefined symbol

HI,

I'm at a loss as to why I'm getting an undefined symbol error. I'm pretty
sure I've linked the necessary libraries and included the correct header
files in my test code.

Here is the error:

g++ -DOPENSERVER -c -w -O2 -I. -I/usr/local/include -I/usr/include -I/u/apps
/xerces-c-src_2002-05-10/include test.cpp -o TestParse.o
g++ -DOPENSERVER -L/usr/lib -L/usr/local/lib -I. -I/usr/local/include -I/usr
/include -I/u/apps/xerces-c-src_2002-05-10/include
TestParse.o -L/u/apps/xerces-c-src_2002-05-10/lib -lxerces-c -lstdc++ -lc -l
socket -lz -o TestParse
Undefined                       first referenced
 symbol                             in file
operator<<(ostream &, DOMString const &)TestParse.o
TestParse: fatal error: Symbol referencing errors. No output written to
TestParse
collect2: ld returned 1 exit status
gmake: *** [TestParse] Error 1

I've copied a couple of lines from the DOMPrint.cpp sample file so I can
have the same type of error reporting:

ostream& operator<<(ostream& target, const DOMString& toWrite);
ostream& operator<<(ostream& target, DOM_Node& toWrite);
XMLFormatter& operator<< (XMLFormatter& strm, const DOMString& s);

These are the header files I'm including in my test code:

#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/util/XMLString.hpp>
#include <xercesc/util/XMLUniDefs.hpp>
#include <xercesc/framework/XMLFormatter.hpp>
#include <xercesc/util/TranscodingException.hpp>
#include <xercesc/dom/DOM_DOMException.hpp>
#include <xercesc/parsers/DOMParser.hpp>
#include <xercesc/dom/DOM.hpp>
#include <xercesc/util/XercesDefs.hpp>
#include <xercesc/sax/ErrorHandler.hpp>
#include <iostream.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>

I've tried to copy the command line option from the samples that were
provided. Just can't seem to get rid of this undefined symbol error. What
library am I not linking with?

Thanks,
Sam


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


RE: Off Topic - gmake code undefined symbol

Posted by Samantha Savvakis <sa...@cfs.net.au>.
ok, please put the "idiot" tag on my forhead :)

Thanks for the quick response!

  -----Original Message-----
  From: Martin Kalen [mailto:martin.kalen@todaysystems.com.au]
  Sent: Tuesday, 14 May 2002 12:43 PM
  To: xerces-c-dev@xml.apache.org
  Subject: Re: Off Topic - gmake code undefined symbol


  > Undefined                       first referenced
  >  symbol                             in file
  > operator<<(ostream &, DOMString const &)TestParse.o

  You are probably just lacking the implementation of this operator. Check
the actual symbols in your program with something like:
  nm -C myprogram | grep '<<'
  'U' means undefined, and 'T' means the symbol is in the text section (i.e.
real code)

  The following line is just a forward declaration, stating that the
implementation is to follow:
  ostream& operator<<(ostream& target, const DOMString& toWrite);

  Later on in DOMPrint.cpp you have the actual implementation:


// -------------------------------------------------------------------------
--
  //  ostream << DOMString
  //
  //  Stream out a DOM string. Doing this requires that we first transcode
  //  to char * form in the default code page for the system


// -------------------------------------------------------------------------
--
  ostream& operator<< (ostream& target, const DOMString& s)
  {
      char *p = s.transcode();
      target << p;
      delete [] p;
      return target;
  }

Re: Off Topic - gmake code undefined symbol

Posted by Martin Kalen <ma...@todaysystems.com.au>.
> Undefined                       first referenced
>  symbol                             in file
> operator<<(ostream &, DOMString const &)TestParse.o

You are probably just lacking the implementation of this operator. Check the actual symbols in your program with something like:
nm -C myprogram | grep '<<'
'U' means undefined, and 'T' means the symbol is in the text section (i.e. real code)

The following line is just a forward declaration, stating that the implementation is to follow:
ostream& operator<<(ostream& target, const DOMString& toWrite);

Later on in DOMPrint.cpp you have the actual implementation:
// ---------------------------------------------------------------------------
//  ostream << DOMString
//
//  Stream out a DOM string. Doing this requires that we first transcode
//  to char * form in the default code page for the system
// ---------------------------------------------------------------------------
ostream& operator<< (ostream& target, const DOMString& s)
{
    char *p = s.transcode();
    target << p;
    delete [] p;
    return target;
}