You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xerces.apache.org by Kelly Beard <ke...@gmail.com> on 2010/01/04 23:04:28 UTC

Unresolved externals after extending DefaultHandler

I'm changing some stuff around in my code and trying to use a SAX2
parser instead of the DOM one I was using before.  I've done this
before in a test program and a production one, but I'm getting some
unresolved externals when I shouldn't be.  I am creating a DOM
document as a result of the XML that gets parsed on the front end.
Can mixing the SAX2 and DOM stuff cause some clashes?  It shouldn't
because I'm doing it in a production program too.  Anyway, this has me
scratching my head a bit.

I'm extending the DefaultHandler class.  The doc says I can just
redefine the pieces I want unless I'm writing a new parser which I'm
not.

#include <xercesc/sax2/DefaultHandler.hpp>

...

class AuthNotifyHandler : public DefaultHandler {
private :
    bool fSawErrors;
    multimap<int, string> errors;
    string elementData;
    string stationCode, stationDate, stationTime, startCode, poNum,
msgID, track1, track2;

public :
    void startDocument();
    void endDocument();
    void startElement(const XMLCh* const uri, const XMLCh* const
localname, const XMLCh* const qname, const Attributes& attrs);
    void characters(const XMLCh *const chars, const unsigned int length);
    void endElement(const XMLCh *const uri, const XMLCh *const
localname, const XMLCh *const qname);
    void error(const SAXParseException &exc);
    void fatalError(const SAXParseException&);
    void warning(const SAXParseException &exc);
    void resetErrors();
    void addError(int code, string text);
    bool hasErrors() { return errors.size() != 0; }
    multimap<int, string> getErrors() { return errors; }

    string getStationCode() { return stationCode; }
    string getStationDate() { return stationDate; }
    string getStationTime() { return stationTime; }
    string getStartCode() { return startCode; }
    string getPONum() { return poNum; }
    string getTrack1() { return track1; }
    string getTrack2() { return track2; }
    string getMsgID() { return msgID; }
};


Definition not found for symbol
'__vft17AuthNotifyHandlerQ2_11xercesc_2_614EntityResolver'.
Definition not found for symbol
'__vft17AuthNotifyHandlerQ2_11xercesc_2_610DTDHandler'.
Definition not found for symbol
'__vft17AuthNotifyHandlerQ2_11xercesc_2_614ContentHandler'.
Definition not found for symbol
'__vft17AuthNotifyHandlerQ2_11xercesc_2_612ErrorHandler'.
Definition not found for symbol
'__vft17AuthNotifyHandlerQ2_11xercesc_2_614LexicalHandler'.
Definition not found for symbol
'__vft17AuthNotifyHandlerQ2_11xercesc_2_611DeclHandler'.

-- 
Kelly Beard

Re: Unresolved externals after extending DefaultHandler

Posted by Kelly Beard <ke...@gmail.com>.
I found the problem, apparently.  I had a declaration for "void
startDocument();" but no actual code for it.  Not really sure how the
compiler let this get through but I created an empty function,
recompiled and got no link errors.  Thanks for your suggestions
though.

On Tue, Jan 5, 2010 at 4:30 PM, David Bertoni <db...@apache.org> wrote:
> On 1/4/2010 2:04 PM, Kelly Beard wrote:
>>
>> I'm changing some stuff around in my code and trying to use a SAX2
>> parser instead of the DOM one I was using before.  I've done this
>> before in a test program and a production one, but I'm getting some
>> unresolved externals when I shouldn't be.  I am creating a DOM
>> document as a result of the XML that gets parsed on the front end.
>> Can mixing the SAX2 and DOM stuff cause some clashes?  It shouldn't
>> because I'm doing it in a production program too.  Anyway, this has me
>> scratching my head a bit.
>>
>> I'm extending the DefaultHandler class.  The doc says I can just
>> redefine the pieces I want unless I'm writing a new parser which I'm
>> not.
>>
>> #include<xercesc/sax2/DefaultHandler.hpp>
>>
>> ...
>>
>> class AuthNotifyHandler : public DefaultHandler {
>> private :
>>     bool fSawErrors;
>>     multimap<int, string>  errors;
>>     string elementData;
>>     string stationCode, stationDate, stationTime, startCode, poNum,
>> msgID, track1, track2;
>>
>> public :
>>     void startDocument();
>>     void endDocument();
>>     void startElement(const XMLCh* const uri, const XMLCh* const
>> localname, const XMLCh* const qname, const Attributes&  attrs);
>>     void characters(const XMLCh *const chars, const unsigned int length);
>>     void endElement(const XMLCh *const uri, const XMLCh *const
>> localname, const XMLCh *const qname);
>>     void error(const SAXParseException&exc);
>>     void fatalError(const SAXParseException&);
>>     void warning(const SAXParseException&exc);
>>     void resetErrors();
>>     void addError(int code, string text);
>
> Did you mean to past this string parameter by value?
>
>>     bool hasErrors() { return errors.size() != 0; }
>
> You might want to use errors.empty() here, instead of comparing with the
> size.
>
>>     multimap<int, string>  getErrors() { return errors; }
>
> Did you mean to return a copy of the map?
>
>>
>>     string getStationCode() { return stationCode; }
>>     string getStationDate() { return stationDate; }
>>     string getStationTime() { return stationTime; }
>>     string getStartCode() { return startCode; }
>>     string getPONum() { return poNum; }
>>     string getTrack1() { return track1; }
>>     string getTrack2() { return track2; }
>>     string getMsgID() { return msgID; }
>> };
>>
>>
>> Definition not found for symbol
>> '__vft17AuthNotifyHandlerQ2_11xercesc_2_614EntityResolver'.
>> Definition not found for symbol
>> '__vft17AuthNotifyHandlerQ2_11xercesc_2_610DTDHandler'.
>> Definition not found for symbol
>> '__vft17AuthNotifyHandlerQ2_11xercesc_2_614ContentHandler'.
>> Definition not found for symbol
>> '__vft17AuthNotifyHandlerQ2_11xercesc_2_612ErrorHandler'.
>> Definition not found for symbol
>> '__vft17AuthNotifyHandlerQ2_11xercesc_2_614LexicalHandler'.
>> Definition not found for symbol
>> '__vft17AuthNotifyHandlerQ2_11xercesc_2_611DeclHandler'.
>>
> Depending on your compiler, you may need to define at least one "key"
> function so the compiler emits the definitions for the virtual tables. What
> happens if you declare and define a default constructor or the destructor in
> a source file?
>
> Dave
>



-- 
Kelly Beard

Re: Unresolved externals after extending DefaultHandler

Posted by David Bertoni <db...@apache.org>.
On 1/4/2010 2:04 PM, Kelly Beard wrote:
> I'm changing some stuff around in my code and trying to use a SAX2
> parser instead of the DOM one I was using before.  I've done this
> before in a test program and a production one, but I'm getting some
> unresolved externals when I shouldn't be.  I am creating a DOM
> document as a result of the XML that gets parsed on the front end.
> Can mixing the SAX2 and DOM stuff cause some clashes?  It shouldn't
> because I'm doing it in a production program too.  Anyway, this has me
> scratching my head a bit.
>
> I'm extending the DefaultHandler class.  The doc says I can just
> redefine the pieces I want unless I'm writing a new parser which I'm
> not.
>
> #include<xercesc/sax2/DefaultHandler.hpp>
>
> ...
>
> class AuthNotifyHandler : public DefaultHandler {
> private :
>      bool fSawErrors;
>      multimap<int, string>  errors;
>      string elementData;
>      string stationCode, stationDate, stationTime, startCode, poNum,
> msgID, track1, track2;
>
> public :
>      void startDocument();
>      void endDocument();
>      void startElement(const XMLCh* const uri, const XMLCh* const
> localname, const XMLCh* const qname, const Attributes&  attrs);
>      void characters(const XMLCh *const chars, const unsigned int length);
>      void endElement(const XMLCh *const uri, const XMLCh *const
> localname, const XMLCh *const qname);
>      void error(const SAXParseException&exc);
>      void fatalError(const SAXParseException&);
>      void warning(const SAXParseException&exc);
>      void resetErrors();
>      void addError(int code, string text);
Did you mean to past this string parameter by value?

>      bool hasErrors() { return errors.size() != 0; }
You might want to use errors.empty() here, instead of comparing with the 
size.

>      multimap<int, string>  getErrors() { return errors; }
Did you mean to return a copy of the map?

>
>      string getStationCode() { return stationCode; }
>      string getStationDate() { return stationDate; }
>      string getStationTime() { return stationTime; }
>      string getStartCode() { return startCode; }
>      string getPONum() { return poNum; }
>      string getTrack1() { return track1; }
>      string getTrack2() { return track2; }
>      string getMsgID() { return msgID; }
> };
>
>
> Definition not found for symbol
> '__vft17AuthNotifyHandlerQ2_11xercesc_2_614EntityResolver'.
> Definition not found for symbol
> '__vft17AuthNotifyHandlerQ2_11xercesc_2_610DTDHandler'.
> Definition not found for symbol
> '__vft17AuthNotifyHandlerQ2_11xercesc_2_614ContentHandler'.
> Definition not found for symbol
> '__vft17AuthNotifyHandlerQ2_11xercesc_2_612ErrorHandler'.
> Definition not found for symbol
> '__vft17AuthNotifyHandlerQ2_11xercesc_2_614LexicalHandler'.
> Definition not found for symbol
> '__vft17AuthNotifyHandlerQ2_11xercesc_2_611DeclHandler'.
>
Depending on your compiler, you may need to define at least one "key" 
function so the compiler emits the definitions for the virtual tables. 
What happens if you declare and define a default constructor or the 
destructor in a source file?

Dave