willem_liu
asked on
Can't use Xerces-C. Compilation Error.
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_IOSTREA MS)
#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::Initiali ze();
}
catch (const XMLException& toCatch)
{
// Do your failure processing here
return 1;
}
// Do your actual work with Xerces-C++ here.
XMLPlatformUtils::Terminat e();
// 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/xe rces-c-src _2_7_0/lib /libxerces -c.so -I/usr/il_kernel/xerces/xe rces-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::fgXe rcescDefau ltLocale'
/tmp/ccUYy9te.o(.text+0x1c ): undefined reference to `xercesc_2_7::XMLPlatformU tils::Init ialize(cha r const *, char const *, xercesc_2_7::PanicHandler *, xercesc_2_7::MemoryManager *, bool)'
/tmp/ccUYy9te.o(.text+0x31 ): undefined reference to `xercesc_2_7::XMLPlatformU tils::Term inate(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?
==========================
#include <xercesc/dom/DOM.hpp>
// Other include files, declarations, and non-Xerces-C++ initializations.
#if defined(XERCES_NEW_IOSTREA
#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::Initiali
}
catch (const XMLException& toCatch)
{
// Do your failure processing here
return 1;
}
// Do your actual work with Xerces-C++ here.
XMLPlatformUtils::Terminat
// 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/xe
/tmp/ccUYy9te.o: In function `main':
/tmp/ccUYy9te.o(.text+0x17
/tmp/ccUYy9te.o(.text+0x1c
/tmp/ccUYy9te.o(.text+0x31
/tmp/ccUYy9te.o(.text+0x49
collect2: ld returned 1 exit status
gmake: *** [sample1] Error 1
==========================
Do you know what I'm doing wrong here?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I'll be trying it and see how it works.
ASKER
Thanks alot for your help! I can't imagine how simple this actually was:D
-L specifies the directory where to look for the shared library, therefore your cmdline should look like :
g++ -L/usr/il_kernel/xerces/xe