You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by "Andreas B. Thun" <ab...@gmx.net> on 2003/03/18 11:56:48 UTC
cannot compile my simple example
Hi!
I want to parse an XML file for it's elements
and attributes (I´d like to use the DOM parser).
Unfortunately I get errors when compiling my
simple program DomParse.cpp.
The makefile seems ok to me but it is obv. not
Can anybody help?
Regards,
Andi
My program DomParse.cpp:
-----------------------------------------------
#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/dom/DOM.hpp>
#include <xercesc/parsers/XercesDOMParser.hpp>
#include <xercesc/util/XMLUniDefs.hpp>
#include <string.h>
#include <stdlib.h>
int main (int argc, char* args[]) {
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;
}
...
}
Compilation:
------------
g++ DomParse.cpp -I/user/abt/xerces/xerces-c-src2_2_0/include/ -L/user/abt/xerces/xerces-c-src2_2_0/lib/ -lxerces-c -o DomParse.o
DomParse.cpp: In function `int main(int, char**)':
DomParse.cpp:21: `XMLPlatformUtils' undeclared (first use this function)
Makefile:
---------
CFLAGS = -w -O -DAPP_NO_THREADS -DXML_USE_NO_THREADS
INCLUDE_DIR = /user/abt/xerces/xerces-c-src2_2_0/include/
LIB_DIR = /user/abt/xerces/xerces-c-src2_2_0/lib/
SRC = DomParse.cpp
OBJ = DomParse.o
#----------------------------------------------------------------
# use g++
#----------------------------------------------------------------
COMPILER = g++
all : $(OBJ)
$(COMPILER) $(CFLAGS) -o DomParse $(OBJ)
#----------------------------------------------------------------
# object files
#----------------------------------------------------------------
DomParse.o : DomParse.cpp
$(COMPILER) $(SRC) -I$(INCLUDE_DIR) -L$(LIB_DIR) -lxerces-c -o $(OBJ)
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
Re: was: cannot compile my simple example: now: Problems with libstdc++
Posted by "Andreas B. Thun" <ab...@gmx.net>.
Finally, I linked libstdc++.so.2.7.1 to libstdc++.so.5.0.0 (see below) and the parser
works, but I am a bit nervous about this. Does anybody know, why the
libstdc++.so.2.7.1 is needed?
/usr/local/lib>
-rw-r--r-- 1 root other 8522420 Feb 3 17:08 libstdc++.a
-rwxr-xr-x 1 root other 1334 Feb 3 17:08 libstdc++.la*
lrwxrwxrwx 1 root other 18 Feb 3 17:08 libstdc++.so -> libstdc++.so.5.0.0*
lrwxrwxrwx 1 root other 18 Mar 18 17:37 libstdc++.so.2.7.1 -> libstdc++.so.5.0.0*
lrwxrwxrwx 1 root other 18 Feb 3 17:08 libstdc++.so.5 -> libstdc++.so.5.0.0*
-rwxr-xr-x 1 root other 2396293 Feb 3 17:08 libstdc++.so.5.0.0*
Still have the ld warning, anyway:
/bin/ld: warning: libstdc++.so.5, needed by /user/abt/xerces/xerces-c-src2_2_0/l
ib/libxerces-c.so, may conflict with libstdc++.so.2.7.1
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
Re: cannot compile my simple example
Posted by "Andreas B. Thun" <ab...@gmx.net>.
Ah, yes. Good hint. Compilation runs now but linking
is bad:
linking:
--------
g++ -I/xerces/xerces-c-src2_2_0/include -L/xerces/xerces-c-sr 2_2_0/lib -lxerces-c \
-o DomParse DOMPrintErrorHandler.o DOMTreeErrorReporter.o DomParse.o
/bin/ld: warning: libstdc++.so.5, needed by /user/abt/xerces/xerces-c-src2_2_0/l
ib/libxerces-c.so, may conflict with libstdc++.so.2.7.1
libstdc++.so.5 is installed!
----------------------------
/usr/local/lib:
-rw-r--r-- 1 root other 8522420 Feb 3 17:08 libstdc++.a
-rwxr-xr-x 1 root other 1334 Feb 3 17:08 libstdc++.la*
lrwxrwxrwx 1 root other 18 Feb 3 17:08 libstdc++.so -> libstdc++.so.5.0.0*
lrwxrwxrwx 1 root other 18 Feb 3 17:08 libstdc++.so.5 -> libstdc++.so.5.0.0*
-rwxr-xr-x 1 root other 2396293 Feb 3 17:08 libstdc++.so.5.0.0*
Makefile:
---------
CFLAGS =
INCLUDE_DIR = /user/abt/xerces/xerces-c-src2_2_0/include
LIB_DIR = /user/abt/xerces/xerces-c-src2_2_0/lib
SRC = DOMPrintErrorHandler.cpp DOMTreeErrorReporter.cpp DomParse.cpp
OBJ = DOMPrintErrorHandler.o DOMTreeErrorReporter.o DomParse.o
#----------------------------------------------------------------
# use g++
#----------------------------------------------------------------
COMPILER = g++
all : $(OBJ)
$(COMPILER) $(CFLAGS) -I$(INCLUDE_DIR) -L$(LIB_DIR) -lxerces-c -o DomParse $(OBJ)
#----------------------------------------------------------------
# object files
#----------------------------------------------------------------
DomParse.o : DomParse.cpp \
DOMTreeErrorReporter.hpp \
DOMPrintErrorHandler.hpp
$(COMPILER) -c $(CFLAGS) -I$(INCLUDE_DIR) -L$(LIB_DIR) -o DomParse.o DomParse.cpp
DOMPrintErrorHandler.o : DOMPrintErrorHandler.cpp
$(COMPILER) -c $(CFLAGS) -I$(INCLUDE_DIR) -L$(LIB_DIR) -o DOMPrintErrorHandler.o DOMPrintErrorHandler.cpp
DOMTreeErrorReporter.o : DOMTreeErrorReporter.cpp
$(COMPILER) -c $(CFLAGS) -I$(INCLUDE_DIR) -L$(LIB_DIR) -o DOMTreeErrorReporter.o DOMTreeErrorReporter.cpp
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
Re: cannot compile my simple example
Posted by Alberto Massari <am...@progress.com>.
At 11.56 18/03/2003 +0100, Andreas B. Thun wrote:
>Hi!
>
>I want to parse an XML file for it's elements
>and attributes (I´d like to use the DOM parser).
>Unfortunately I get errors when compiling my
>simple program DomParse.cpp.
>The makefile seems ok to me but it is obv. not
>Can anybody help?
>
>Regards,
>Andi
>
>
>
>My program DomParse.cpp:
>-----------------------------------------------
>#include <xercesc/util/PlatformUtils.hpp>
>#include <xercesc/dom/DOM.hpp>
>#include <xercesc/parsers/XercesDOMParser.hpp>
>#include <xercesc/util/XMLUniDefs.hpp>
>
>#include <string.h>
>#include <stdlib.h>
You need to add a
XERCES_CPP_NAMESPACE_USE
command here.
Alberto
>int main (int argc, char* args[]) {
>
> 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;
> }
> ...
>}
>
>
>Compilation:
>------------
>g++ DomParse.cpp -I/user/abt/xerces/xerces-c-src2_2_0/include/
>-L/user/abt/xerces/xerces-c-src2_2_0/lib/ -lxerces-c -o DomParse.o
>
>DomParse.cpp: In function `int main(int, char**)':
>DomParse.cpp:21: `XMLPlatformUtils' undeclared (first use this function)
>
>
>
>Makefile:
>---------
>CFLAGS = -w -O -DAPP_NO_THREADS -DXML_USE_NO_THREADS
>INCLUDE_DIR = /user/abt/xerces/xerces-c-src2_2_0/include/
>LIB_DIR = /user/abt/xerces/xerces-c-src2_2_0/lib/
>
>SRC = DomParse.cpp
>
>OBJ = DomParse.o
>
>#----------------------------------------------------------------
># use g++
>#----------------------------------------------------------------
>COMPILER = g++
>
>all : $(OBJ)
> $(COMPILER) $(CFLAGS) -o DomParse $(OBJ)
>
>
>#----------------------------------------------------------------
># object files
>#----------------------------------------------------------------
>DomParse.o : DomParse.cpp
> $(COMPILER) $(SRC) -I$(INCLUDE_DIR) -L$(LIB_DIR) -lxerces-c -o $(OBJ)
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
>For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org