Xerces Compilation Issue

Discussion in 'C++' started by mearvk, Oct 3, 2007.

  1. mearvk

    mearvk Guest

    Hello,

    Let me preface this post by saying I'm new to C/C++ and to gcc/g++.
    Now then, I'm trying to get Xerces (C++) working on a (64-bit) redhat
    machine. The Xerces binaries were part of the Redhat distribition, and
    are under /usr/lib64/httpd/.../xerces/ (Apache's stuff right?). Below
    is the (simple) source file I am trying to compile:



    #include <xercesc/util/PlatformUtils.hpp>
    #include <iostream>

    XERCES_CPP_NAMESPACE_USE

    int main(int argc, char* argv[])
    {

    try
    {
    XMLPlatformUtils::Initialize();
    }
    catch (const XMLException& toCatch)
    {
    // Do your failure processing here
    return 1;
    }

    // Do your actual work with Xerces-C++ here.

    std::cout << "Hello, world!\n";


    //Terminate DDAS_XML_Parser
    XMLPlatformUtils::Terminate();

    // Other terminations and cleanup.
    return 0;
    }


    The following command runs without error:

    $ g++ -Wall -c DDAS_XML_Parser.C -L/usr/lib64/httpd/modules/xerces/
    xerces-c-redhat_AS4-gcc_343/lib -I/usr/lib64/httpd/modules/xerces/
    xerces-c-redhat_AS4-gcc_343/include

    Now I get the following errors when I try to compile this program as
    an executable:

    $ g++ -Wall DDAS_XML_Parser.o -o DDAS_XML_Parser

    DDAS_XML_Parser.o(.text+0x135): In function `main':
    : undefined reference to `xercesc_2_7::XMLUni::fgXercescDefaultLocale'
    DDAS_XML_Parser.o(.text+0x13a): In function `main':
    : undefined reference to
    `xercesc_2_7::XMLPlatformUtils::Initialize(char const*, char const*,
    xercesc_2_7::panicHandler*, xercesc_2_7::MemoryManager*, bool)'
    DDAS_XML_Parser.o(.text+0x17e): In function `main':
    : undefined reference to `xercesc_2_7::XMLPlatformUtils::Terminate()'
    DDAS_XML_Parser.o(.gcc_except_table+0x10): undefined reference to
    `typeinfo for xercesc_2_7::XMLException'
    collect2: ld returned 1 exit status



    I have already defined the LD_LIBRARY_PATH to point to the location of
    the ../lib folder which contains the .so files and the C_PLUS_INCLUDE
    points to the ../include location. So the explicit command line
    references are just making sure (in my mind) that g++ sees those
    folders. But it's like the compiler doesn't see the .so files, even
    though I think I'm telling it (twice) where it is.

    Please let me know if I've left out any pertinent data needed for
    diagnosis.

    Help is greatly appreciated and thanks ahead of time,

    Max
    mearvk, Oct 3, 2007
    #1
    1. Advertising

  2. On Oct 3, 4:56 am, mearvk <> wrote:
    > The following command runs without error:
    >
    > $ g++ -Wall -c DDAS_XML_Parser.C -L/usr/lib64/httpd/modules/xerces/
    > xerces-c-redhat_AS4-gcc_343/lib -I/usr/lib64/httpd/modules/xerces/
    > xerces-c-redhat_AS4-gcc_343/include
    >


    (I've been away from *nix for a while but I'll try ...)
    OK you've compiled your source into an object file. But library
    paths (-L) are irrelevant at this stage.

    > Now I get the following errors when I try to compile this program as
    > an executable:
    > $ g++ -Wall DDAS_XML_Parser.o -o DDAS_XML_Parser


    You're not compiling here - you're trying to link. This is
    where the -L stuff should go, but you've set up an env var so that
    shouldn't matter. BUT you're not specifying WHAT libraries to link:
    try the -l (little ell) option.

    HTH.
    tragomaskhalos, Oct 3, 2007
    #2
    1. Advertising

  3. mearvk

    mearvk Guest

    On Oct 3, 11:11 am, tragomaskhalos <>
    wrote:
    > On Oct 3, 4:56 am, mearvk <> wrote:
    >
    > > The following command runs without error:

    >
    > > $ g++ -Wall -c DDAS_XML_Parser.C -L/usr/lib64/httpd/modules/xerces/
    > > xerces-c-redhat_AS4-gcc_343/lib -I/usr/lib64/httpd/modules/xerces/
    > > xerces-c-redhat_AS4-gcc_343/include

    >
    > (I've been away from *nix for a while but I'll try ...)
    > OK you've compiled your source into an object file. But library
    > paths (-L) are irrelevant at this stage.
    >
    > > Now I get the following errors when I try to compile this program as
    > > an executable:
    > > $ g++ -Wall DDAS_XML_Parser.o -o DDAS_XML_Parser

    >
    > You're not compiling here - you're trying to link. This is
    > where the -L stuff should go, but you've set up an env var so that
    > shouldn't matter. BUT you're not specifying WHAT libraries to link:
    > try the -l (little ell) option.
    >
    > HTH.



    I've tried the explicit -L and -I flags to link and nothing. Even did
    a ldconfig -v and a ldconfig -p ../lib to no avail.

    Any other ideas?

    Thanks!
    mearvk, Oct 4, 2007
    #3
  4. On Oct 4, 5:38 am, mearvk <> wrote:
    > On Oct 3, 11:11 am, tragomaskhalos <>
    > wrote:
    >
    > > You're not compiling here - you're trying to link. This is
    > > where the -L stuff should go, but you've set up an env var so that
    > > shouldn't matter. BUT you're not specifying WHAT libraries to link:
    > > try the -l (little ell) option.

    >
    > I've tried the explicit -L and -I flags to link and nothing. Even did
    > a ldconfig -v and a ldconfig -p ../lib to no avail.
    >
    > Any other ideas?
    >


    1. Did you try my suggestion and research the -l (little ell)
    option? This should do it for .a libraries, you may need
    something else if xerces is a shared library.
    2. Google "man g++" and "man gcc" and RT..M !!
    tragomaskhalos, Oct 4, 2007
    #4
  5. mearvk

    mearvk Guest

    On Oct 4, 5:42 am, tragomaskhalos <>
    wrote:
    > On Oct 4, 5:38 am, mearvk <> wrote:
    >
    > > On Oct 3, 11:11 am, tragomaskhalos <>
    > > wrote:

    >
    > > > You're not compiling here - you're trying to link. This is
    > > > where the -L stuff should go, but you've set up an env var so that
    > > > shouldn't matter. BUT you're not specifying WHAT libraries to link:
    > > > try the -l (little ell) option.

    >
    > > I've tried the explicit -L and -I flags to link and nothing. Even did
    > > a ldconfig -v and a ldconfig -p ../lib to no avail.

    >
    > > Any other ideas?

    >
    > 1. Did you try my suggestion and research the -l (little ell)
    > option? This should do it for .a libraries, you may need
    > something else if xerces is a shared library.
    > 2. Google "man g++" and "man gcc" and RT..M !!


    Yes I tried the -l option. Even if I'm in /usr/lib/ or lib64 all I get
    when using -lxerces-c is that the versions that ld sees are all
    incompatible.
    mearvk, Oct 4, 2007
    #5
  6. On Oct 4, 6:27 pm, mearvk <> wrote:
    >
    > Yes I tried the -l option. Even if I'm in /usr/lib/ or lib64 all I get
    > when using -lxerces-c is that the versions that ld sees are all
    > incompatible.- Hide quoted text -
    >


    In that case all I can suggest is try a newsgroup dedicated to
    g++ / gcc - hopefully those guys will have seen this before.
    Good luck.
    tragomaskhalos, Oct 5, 2007
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Praveen Chhangani

    Xerces Classpath Issue

    Praveen Chhangani, Oct 17, 2003, in forum: Java
    Replies:
    1
    Views:
    494
    David Zimmerman
    Oct 18, 2003
  2. cvissy
    Replies:
    0
    Views:
    601
    cvissy
    Nov 16, 2004
  3. Mani
    Replies:
    0
    Views:
    544
  4. Nicolas
    Replies:
    3
    Views:
    809
    Joseph Kesselman
    Feb 22, 2006
  5. C__chp
    Replies:
    4
    Views:
    493
    Puppet_Sock
    Feb 15, 2008
Loading...

Share This Page