Problem with Apache XML C++ Parser library

This is a discussion on Problem with Apache XML C++ Parser library within the C++ Programming forums, part of the General Programming Boards category; Ok, I try to make application using xml library. My configuration data will be stored in xml files. So.... I ...

  1. #1
    Registered User gandalf_bar's Avatar
    Join Date
    Oct 2003
    Posts
    92

    Problem with Apache XML C++ Parser library

    Ok, I try to make application using xml library. My configuration data will be stored in xml files. So....
    I downloaded library from here:
    http://xml.apache.org/xerces-c/index.html

    Ok, I have unpacked it to here:
    /home/gandalf_bar/
    So the library files are here:
    /home/gandalf_bar/xerces/include

    I have put the libraries to LD_LIBRARY_PATH so I can run the example without problem.

    But I don't know how to compile one single application with this library. I try to read the document. But I cann't find it.

    Consider this simple code:
    Code:
    #include <xercesc/parsers/XercesDOMParser.hpp>
    #include <xercesc/dom/DOM.hpp>
    #include <xercesc/sax/HandlerBase.hpp>
    #include <xercesc/util/XMLString.hpp>
    #include <xercesc/util/PlatformUtils.hpp>
    #include <iostream>
    using namespace std;
    
    int main( int argc, char* argv[] )
    {
       try
       {
          XMLPlatformUtils::Initialize();
       }
       catch( const XMLException& toCatch )
       {
          char* message = XMLString::transcode( toCatch.getMessage() );
          cout << "Error during initialization! :\n" 
    	   << message << "\n";
          XMLString::release( &message );
          return 1;
       }
    }
    When I do this:
    $ g++ hello.cpp -o hello
    hello.cpp:1:47: xercesc/parsers/XercesDOMParser.hpp: No such file or directory
    hello.cpp:2:42: xercesc/util/PlatformUtils.hpp: No such file or directory
    hello.cpp:3:38: xercesc/util/XMLString.hpp: No such file or directory
    hello.cpp:4:31: xercesc/dom/DOM.hpp: No such file or directory
    hello.cpp:5:39: xercesc/sax/HandlerBase.hpp: No such file or directory
    hello.cpp:6:38: xercesc/util/XMLString.hpp: No such file or directory
    hello.cpp:7:42: xercesc/util/PlatformUtils.hpp: No such file or directory
    hello.cpp: In function `int main(int, char**)':
    hello.cpp:15: error: `XMLPlatformUtils' undeclared (first use this function)
    hello.cpp:15: error: (Each undeclared identifier is reported only once for each
    function it appears in.)
    hello.cpp:15: error: parse error before `::' token
    hello.cpp:17: error: parse error before `&' token
    hello.cpp:21: error: `message' undeclared (first use this function)
    hello.cpp:22: error: `XMLString' undeclared (first use this function)
    hello.cpp:22: error: parse error before `::' token
    hello.cpp: At global scope:
    hello.cpp:25: error: parse error before `}' token

    But if I do this:
    $ g++ -o hello hello.cpp -I /home/gandalf_bar/xerces/include
    hello.cpp: In function `int main(int, char**)':
    hello.cpp:15: error: `XMLPlatformUtils' undeclared (first use this function)
    hello.cpp:15: error: (Each undeclared identifier is reported only once for each
    function it appears in.)
    hello.cpp:15: error: parse error before `::' token
    hello.cpp:17: error: parse error before `&' token
    hello.cpp:21: error: `message' undeclared (first use this function)
    hello.cpp:22: error: `XMLString' undeclared (first use this function)
    hello.cpp:22: error: parse error before `::' token
    hello.cpp: At global scope:
    hello.cpp:25: error: parse error before `}' token

    So is there anyone outthere have experience using this xml parser library and want to help me compiling the application using this library?

    Thank you.
    A man asked, "Who are you?"
    Buddha answered, "I am awaked."

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Well, since it apparently doesn't like your path, how about using the whole path?
    Code:
    #include "/home/gandalf_bar/xerces/include/whatever/whatever/whatever.hpp"
    As a general rule, take the very first error or warning, fix it, and attempt your compile again. Repeat until you've got no errors and warnings.

    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Registered User gandalf_bar's Avatar
    Join Date
    Oct 2003
    Posts
    92
    Got it! I have to do this way:
    g++ -o hello hello.cpp -I /path/to/include -L /path/to/lib -lpthread -lxerces-c

    And in the file I have to put this statement:
    XERCES_CPP_NAMESPACE_USE

    Very confusing.
    Thank you.
    A man asked, "Who are you?"
    Buddha answered, "I am awaked."

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. parser problem.
    By Luigi in forum C++ Programming
    Replies: 1
    Last Post: 04-05-2003, 07:22 PM
  2. HELP!!! Apache Problem :(
    By *Michelle* in forum Tech Board
    Replies: 15
    Last Post: 02-16-2003, 01:38 AM
  3. Library Linking problem
    By Lynchie in forum C Programming
    Replies: 3
    Last Post: 07-23-2002, 08:49 AM
  4. Library Problem - [I Think]
    By White Chocobo in forum C Programming
    Replies: 1
    Last Post: 04-25-2002, 08:50 PM
  5. problem with output
    By Garfield in forum C Programming
    Replies: 2
    Last Post: 11-18-2001, 07:34 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21