Visualizzazione dei risultati da 1 a 7 su 7
  1. #1
    Utente di HTML.it
    Registrato dal
    Apr 2009
    Messaggi
    81

    Problemi xerces e visual c++ 2008 express edition

    Ciao a tutti, premetto che ora sto cominciando ad approfondire il c++ e già mi trovo difronte ad un problema.
    Devo utilizzare il parser xerces c++ e dopo averlo decompresso e aver aggiornato l'elenco directory per i file di inclusione di Visual c++ 2008 express edition ho provato a compilare ed eseguire il seguente file incluso in un progetto di Visual c++ 2008 ee del tipo Progetto Console Win32:
    codice:
    // prova1.cpp : definisce il punto di ingresso dell'applicazione console.
    //
    
    #include "stdafx.h"
    #include <iostream>
    #include <xercesc/util/PlatformUtils.hpp>
    #include <xercesc/util/XMLString.hpp>
    #include <xercesc/dom/DOM.hpp>
    #include <xercesc/util/OutOfMemoryException.hpp>
    
    #if defined(XERCES_NEW_IOSTREAMS)
    #include <iostream>
    #else
    #include <iostream.h>
    #endif
    
    
    XERCES_CPP_NAMESPACE_USE
    
    // ---------------------------------------------------------------------------
    //  This is a simple class that lets us do easy (though not terribly efficient)
    //  trancoding of char* data to XMLCh data.
    // ---------------------------------------------------------------------------
    class XStr
    {
    public :
        // -----------------------------------------------------------------------
        //  Constructors and Destructor
        // -----------------------------------------------------------------------
        XStr(const char* const toTranscode)
        {
            // Call the private transcoding method
            fUnicodeForm = XMLString::transcode(toTranscode);
        }
    
        ~XStr()
        {
            XMLString::release(&fUnicodeForm);
        }
    
    
        // -----------------------------------------------------------------------
        //  Getter methods
        // -----------------------------------------------------------------------
        const XMLCh* unicodeForm() const
        {
            return fUnicodeForm;
        }
    
    private :
        // -----------------------------------------------------------------------
        //  Private data members
        //
        //  fUnicodeForm
        //      This is the Unicode XMLCh format of the string.
        // -----------------------------------------------------------------------
        XMLCh*   fUnicodeForm;
    };
    
    #define X(str) XStr(str).unicodeForm()
    
    
    // ---------------------------------------------------------------------------
    //  main
    // ---------------------------------------------------------------------------
    
    int main(int argC, char*[])
    {
        // Initialize the XML4C2 system.
        try
        {
            XMLPlatformUtils::Initialize();
        }
    
        catch(const XMLException& toCatch)
        {
            char *pMsg = XMLString::transcode(toCatch.getMessage());
            XERCES_STD_QUALIFIER cerr << "Error during Xerces-c Initialization.\n"
                 << "  Exception message:"
                 << pMsg;
            XMLString::release(&pMsg);
            return 1;
        }
    
        // Watch for special case help request
        int errorCode = 0;
        if (argC > 1)
        {
            XERCES_STD_QUALIFIER cout << "\nUsage:\n"
                    "    CreateDOMDocument\n\n"
                    "This program creates a new DOM document from scratch in memory.\n"
                    "It then prints the count of elements in the tree.\n"
                 << XERCES_STD_QUALIFIER endl;
            errorCode = 1;
        }
        if(errorCode) {
            XMLPlatformUtils::Terminate();
            return errorCode;
        }
    
       {
           //  Nest entire test in an inner block.
           //  The tree we create below is the same that the XercesDOMParser would
           //  have created, except that no whitespace text nodes would be created.
    
           // <company>
           //     <product>Xerces-C</product>
           //     <category idea='great'>XML Parsing Tools</category>
           //     <developedBy>Apache Software Foundation</developedBy>
           // </company>
    
           DOMImplementation* impl =  DOMImplementationRegistry::getDOMImplementation(X("Core"));
    
           if (impl != NULL)
           {
               try
               {
                   DOMDocument* doc = impl->createDocument(
                               0,                    // root element namespace URI.
                               X("company"),         // root element name
                               0);                   // document type object (DTD).
    
                   DOMElement* rootElem = doc->getDocumentElement();
    
                   DOMElement*  prodElem = doc->createElement(X("product"));
                   rootElem->appendChild(prodElem);
    
                   DOMText*    prodDataVal = doc->createTextNode(X("Xerces-C"));
                   prodElem->appendChild(prodDataVal);
    
                   DOMElement*  catElem = doc->createElement(X("category"));
                   rootElem->appendChild(catElem);
    
                   catElem->setAttribute(X("idea"), X("great"));
    
                   DOMText*    catDataVal = doc->createTextNode(X("XML Parsing Tools"));
                   catElem->appendChild(catDataVal);
    
                   DOMElement*  devByElem = doc->createElement(X("developedBy"));
                   rootElem->appendChild(devByElem);
    
                   DOMText*    devByDataVal = doc->createTextNode(X("Apache Software Foundation"));
                   devByElem->appendChild(devByDataVal);
    
                   //
                   // Now count the number of elements in the above DOM tree.
                   //
    
                   const XMLSize_t elementCount = doc->getElementsByTagName(X("*"))->getLength();
                   XERCES_STD_QUALIFIER cout << "The tree just created contains: " << elementCount
                        << " elements." << XERCES_STD_QUALIFIER endl;
    
                   doc->release();
               }
               catch (const OutOfMemoryException&)
               {
                   XERCES_STD_QUALIFIER cerr << "OutOfMemoryException" << XERCES_STD_QUALIFIER endl;
                   errorCode = 5;
               }
               catch (const DOMException& e)
               {
                   XERCES_STD_QUALIFIER cerr << "DOMException code is:  " << e.code << XERCES_STD_QUALIFIER endl;
                   errorCode = 2;
               }
               catch (...)
               {
                   XERCES_STD_QUALIFIER cerr << "An error occurred creating the document" << XERCES_STD_QUALIFIER endl;
                   errorCode = 3;
               }
           }  // (inpl != NULL)
           else
           {
               XERCES_STD_QUALIFIER cerr << "Requested implementation is not supported" << XERCES_STD_QUALIFIER endl;
               errorCode = 4;
           }
       }
    
       XMLPlatformUtils::Terminate();
       return errorCode;
    }
    La compilazione va a buon termine, ma quando eseguo il debug mi da i seguenti errori:

    Compilazione in corso...
    prova1.cpp
    Collegamento in corso...
    prova1.obj : error LNK2019: riferimento al simbolo esterno "__declspec(dllimport) public: static class xercesc_3_1:OMImplementation * __cdecl xercesc_3_1:OMImplementationRegistry::getDOMImplementation(wch ar_t const *)" (__imp_?getDOMImplementation@DOMImplementationRegi stry@xercesc_3_1@@SAPAVDOMImplementation@2@PB_W@Z) non risolto nella funzione __catch$_main$0
    prova1.obj : error LNK2019: riferimento al simbolo esterno "__declspec(dllimport) public: static void __cdecl xercesc_3_1::XMLPlatformUtils::Terminate(void)" (__imp_?Terminate@XMLPlatformUtils@xercesc_3_1@@SA XXZ) non risolto nella funzione __catch$_main$0
    prova1.obj : error LNK2019: riferimento al simbolo esterno "__declspec(dllimport) public: static void __cdecl xercesc_3_1::XMLString::release(char * *,class xercesc_3_1::MemoryManager * const)" (__imp_?release@XMLString@xercesc_3_1@@SAXPAPADQAV MemoryManager@2@@Z) non risolto nella funzione __catch$_main$0
    prova1.obj : error LNK2019: riferimento al simbolo esterno "__declspec(dllimport) public: static char * __cdecl xercesc_3_1::XMLString::transcode(wchar_t const * const,class xercesc_3_1::MemoryManager * const)" (__imp_?transcode@XMLString@xercesc_3_1@@SAPADQB_W QAVMemoryManager@2@@Z) non risolto nella funzione __catch$_main$0
    prova1.obj : error LNK2019: riferimento al simbolo esterno "__declspec(dllimport) public: wchar_t const * __thiscall xercesc_3_1::XMLException::getMessage(void)const " (__imp_?getMessage@XMLException@xercesc_3_1@@QBEPB _WXZ) non risolto nella funzione __catch$_main$0
    prova1.obj : error LNK2001: simbolo esterno "__declspec(dllimport) public: static class xercesc_3_1::MemoryManager * xercesc_3_1::XMLPlatformUtils::fgMemoryManager" (__imp_?fgMemoryManager@XMLPlatformUtils@xercesc_3 _1@@2PAVMemoryManager@2@A) non risolto
    prova1.obj : error LNK2019: riferimento al simbolo esterno "__declspec(dllimport) public: static void __cdecl xercesc_3_1::XMLPlatformUtils::Initialize(char const * const,char const * const,class xercesc_3_1::PanicHandler * const,class xercesc_3_1::MemoryManager * const)" (__imp_?Initialize@XMLPlatformUtils@xercesc_3_1@@S AXQBD0QAVPanicHandler@2@QAVMemoryManager@2@@Z) non risolto nella funzione _main
    prova1.obj : error LNK2001: simbolo esterno "__declspec(dllimport) public: static char const * const xercesc_3_1::XMLUni::fgXercescDefaultLocale" (__imp_?fgXercescDefaultLocale@XMLUni@xercesc_3_1@ @2QBDB) non risolto
    prova1.obj : error LNK2019: riferimento al simbolo esterno "__declspec(dllimport) public: static wchar_t * __cdecl xercesc_3_1::XMLString::transcode(char const * const,class xercesc_3_1::MemoryManager * const)" (__imp_?transcode@XMLString@xercesc_3_1@@SAPA_WQBD QAVMemoryManager@2@@Z) non risolto nella funzione "public: __thiscall XStr::XStr(char const * const)" (??0XStr@@QAE@QBD@Z)
    prova1.obj : error LNK2019: riferimento al simbolo esterno "__declspec(dllimport) public: static void __cdecl xercesc_3_1::XMLString::release(wchar_t * *,class xercesc_3_1::MemoryManager * const)" (__imp_?release@XMLString@xercesc_3_1@@SAXPAPA_WQA VMemoryManager@2@@Z) non risolto nella funzione "public: __thiscall XStr::~XStr(void)" (??1XStr@@QAE@XZ)
    C:\Documents and Settings\Alessandra\Documenti\Visual Studio 2008\Projects\prova1\Debug\prova1.exe : fatal error LNK1120: 10 esterni non risolti

    A questo punto ho seguito una procedura in cui mi diceva di aggiungere al file stdafx.h le seguenti linee di codice:

    codice:
    template class __declspec(dllimport) CStringT<TCHAR, StrTraitMFC<TCHAR, ChTraitsCRT<TCHAR> > >
    template class __declspec(dllimport) CSimpleStringT<TCHAR>

    ma quando eseguo il debug mi da il seguente errore:
    stdafx.h(14) : error C2059: errore di sintassi:

    Qualcuno ha qualche suggerimento???
    Grazie!!!

  2. #2

    Re: Problemi xerces e visual c++ 2008 express edition

    Originariamente inviato da tina8

    prova1.obj : error LNK2019: riferimento al simbolo esterno "__declspec(dllimport) public: static class xercesc_3_1:OMImplementation * __cdecl xercesc_3_1:OMImplementationRegistry::getDOMImplementation(wch ar_t const *)" (__imp_?getDOMImplementation@DOMImplementationRegi stry@xercesc_3_1@@SAPAVDOMImplementation@2@PB_W@Z) non risolto nella funzione __catch$_main$0
    te lo dice il compilatore stesso: il linker non trova il simbolo tal dei tali.
    Perciò aggiungi al tuo progetto la libreria che lo contiene (probabilmente un xerces.lib).
    ;-)

  3. #3
    Utente di HTML.it
    Registrato dal
    Apr 2009
    Messaggi
    81
    Ciao, non sono ancora riuscita a risolvere il problema, la procedura che ho seguito è la seguente:
    1. Ho scaricato la Source Distributions di xerces
    2. Ho scompattato in C:
    3. Ho aperto il file C:\xerces-c-3.1.0\xerces-c-3.1.0\projects\Win32\VC9\xerces-all\xerces-all.sln
    4. Compilato il progetto XercesLib
    5. Aggiunto nella sezione Progetto->Proprietà->Linker->Input la seguente libreria
    C:\xerces-c-3.1.0\xerces-c-3.1.0\Build\Win32\VC9\Debug\xerces-c_3D.lib
    6. Compilato il progetto senza errori
    7. Ma quando vado ad eseguire il debug mi viene visualizzato il seguente messaggio d'errore:
    Impossibile avviare l'applicazione specificata. xerces-c_3_1D.dll non è stato trovato.

    Se provo ad inserire tale stringa

    C:\xerces-c-3.1.0\xerces-c-3.1.0\Build\Win32\VC9\Debug\xerces-c_3_1D.dll

    all'interno del linker mi dice che il file xerces-c_3_1D.dll è danneggiato.

    Quale potrebbe essere l'errore commesso?
    Grazie e salutiii!!!

  4. #4
    Utente di HTML.it L'avatar di shodan
    Registrato dal
    Jun 2001
    Messaggi
    2,381
    E' corretto mettere il .lib nelle proprietà del linker.
    Poi devi mettere la DLL corretta ( quella di debug ) nella cartella dell'eseguibile.
    This code and information is provided "as is" without warranty of any kind, either expressed
    or implied, including but not limited to the implied warranties of merchantability and/or
    fitness for a particular purpose.

  5. #5
    Utente di HTML.it
    Registrato dal
    Apr 2009
    Messaggi
    81
    Che cosa intendi per cartella dell'eseguibile? O meglio potresti essere più preciso sulla posizione in cui devo inserire il file.dll?

  6. #6
    Utente di HTML.it L'avatar di shodan
    Registrato dal
    Jun 2001
    Messaggi
    2,381
    Sarebbe la cartella del progetto.
    Ad esempio:
    C:\Users\Tina8\Documents\Visual Studio 2008\Projects\xercesproject\xercesproject
    This code and information is provided "as is" without warranty of any kind, either expressed
    or implied, including but not limited to the implied warranties of merchantability and/or
    fitness for a particular purpose.

  7. #7
    Utente di HTML.it
    Registrato dal
    Apr 2009
    Messaggi
    81
    Grazie...risolto!!!!

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.