?
Solved

Can't use Xerces-C. Compilation Error.

Posted on 2006-05-05
4
Medium Priority
?
862 Views
Last Modified: 2012-06-21
This is the code snippet I want to compile called sample1.c:

======================================================================================
#include <xercesc/dom/DOM.hpp>

// Other include files, declarations, and non-Xerces-C++ initializations.

#if defined(XERCES_NEW_IOSTREAMS)
#include <iostream>
#else
#include <iostream.h>
#endif

#ifdef XERCES_CPP_NAMESPACE_USE
XERCES_CPP_NAMESPACE_USE
#endif

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.

      XMLPlatformUtils::Terminate();

      // Other terminations and cleanup.
      return 0;
}
======================================================================================

I've already installed Xerces C correctly as I could compile all the Samples that were included with the Xerces C library.

I get the following error if I use the following makefile to compile the above code:

======================================================================================
gmake
g++ -L/usr/il_kernel/xerces/xerces-c-src_2_7_0/lib/libxerces-c.so -I/usr/il_kernel/xerces/xerces-c-src_2_7_0/src sample1.c -o sample1
/tmp/ccUYy9te.o: In function `main':
/tmp/ccUYy9te.o(.text+0x17): undefined reference to `xercesc_2_7::XMLUni::fgXercescDefaultLocale'
/tmp/ccUYy9te.o(.text+0x1c): undefined reference to `xercesc_2_7::XMLPlatformUtils::Initialize(char const *, char const *, xercesc_2_7::PanicHandler *, xercesc_2_7::MemoryManager *, bool)'
/tmp/ccUYy9te.o(.text+0x31): undefined reference to `xercesc_2_7::XMLPlatformUtils::Terminate(void)'
/tmp/ccUYy9te.o(.text+0x49): undefined reference to `xercesc_2_7::XMLException type_info function'
collect2: ld returned 1 exit status
gmake: *** [sample1] Error 1
======================================================================================

Do you know what I'm doing wrong here?
0
Comment
Question by:willem_liu
  • 2
  • 2
4 Comments
 
LVL 5

Expert Comment

by:Dragon_Krome
ID: 16612943
you have the wrong parameters:

-L specifies the directory where to look for the shared library, therefore your cmdline should look like :

g++ -L/usr/il_kernel/xerces/xerces-c-src_2_7_0/lib -lxerces-c.so -I/usr/il_kernel/xerces/xerces-c-src_2_7_0/src sample1.c -o sample1
0
 
LVL 5

Accepted Solution

by:
Dragon_Krome earned 2000 total points
ID: 16612946
Ups, my fault, this should do it:

g++ -L/usr/il_kernel/xerces/xerces-c-src_2_7_0/lib -lxerces-c -I/usr/il_kernel/xerces/xerces-c-src_2_7_0/src sample1.c -o sample1
0
 

Author Comment

by:willem_liu
ID: 16613084
I'll be trying it and see how it works.
0
 

Author Comment

by:willem_liu
ID: 16613113
Thanks alot for your help! I can't imagine how simple this actually was:D
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question