Operating System - HP-UX
1753928 Members
8983 Online
108810 Solutions
New Discussion юеВ

xerces build using gnu g++ error -- forward declaration error.

 
uiqbal
Advisor

xerces build using gnu g++ error -- forward declaration error.

Hi,

I am trying to build xerces 2.5.0 using g++ version 4.2.3. I have added this to my makefile.incl
http://marc.info/?l=xerces-c-dev&m=113163501028049&w=2

Here are my commands afterwards,
# export XERCESCROOT=/data1/rui/xerces-c-src_2_5_0
and then I execute these commands sitting in the $XERCESCROOT/src/xercesc directory

# runConfigure -php-11 -cgcc -xg++ -z"-fPIC" -minmem -nsocket -tnative -rpthread
# gmake

it compiles for a long time with most of the directories built, but ultimately gives this error, can anybody point me to what could be the problem -- any sort of code modification related to xerces code can be done as i just want to compile and get the lib ready.

mkdir -p /data1/rui/xerces-c-src_2_5_0/include/xercesc/framework/psvi
cp -fp PSVIAttribute.hpp PSVIAttributeList.hpp PSVIElement.hpp PSVIHandler.hpp PSVIItem.hpp XSAnnotation.hpp XSAttributeDeclaration.hpp XSAttributeGroupDefinition.hpp XSAttributeUse.hpp XSComplexTypeDefinition.hpp XSConstants.hpp XSElementDeclaration.hpp XSFacet.hpp XSIDCDefinition.hpp XSModel.hpp XSModelGroup.hpp XSModelGroupDefinition.hpp XSMultiValueFacet.hpp XSNamedMap.hpp XSNamespaceItem.hpp XSNotationDeclaration.hpp XSObject.hpp XSParticle.hpp XSSimpleTypeDefinition.hpp XSTypeDefinition.hpp XSWildcard.hpp XSNamedMap.c /data1/rui/xerces-c-src_2_5_0/include/xercesc/framework/psvi
g++ -fPIC -D_HP_UX -DXERCES_TMPLSINC -DHPUX11 -D_REENTRANT -c -I/data1/rui/xerces-c-src_2_5_0/include -w -O -DPROJ_XMLPARSER -DPROJ_XMLUTIL -DPROJ_PARSERS -DPROJ_SAX4C -DPROJ_SAX2 -DPROJ_DOM -DPROJ_VALIDATORS -DXML_USE_NATIVE_TRANSCODER -DXML_USE_INMEM_MESSAGELOADER -DXML_USE_PTHREADS -DXML_USE_NETACCESSOR_SOCKET -o /data1/rui/xerces-c-src_2_5_0/obj/HPUX/XSAttributeGroupDefinition.o XSAttributeGroupDefinition.cpp

XSAttributeGroupDefinition.cpp: In member function 'virtual const XMLCh* xercesc_2_5::XSAttributeGroupDefinition::getName()':
XSAttributeGroupDefinition.cpp:122: error: invalid use of incomplete type 'struct xercesc_2_5::XMLStringPool'
/data1/rui/xerces-c-src_2_5_0/include/xercesc/framework/psvi/XSNamedMap.hpp:80: error: forward declaration of 'struct xercesc_2_5::XMLStringPool'
XSAttributeGroupDefinition.cpp: In member function 'virtual const XMLCh* xercesc_2_5::XSAttributeGroupDefinition::getNamespace()':
XSAttributeGroupDefinition.cpp:127: error: invalid use of incomplete type 'struct xercesc_2_5::XMLStringPool'
/data1/rui/xerces-c-src_2_5_0/include/xercesc/framework/psvi/XSNamedMap.hpp:80: error: forward declaration of 'struct xercesc_2_5::XMLStringPool'
gmake[2]: *** [XSAttributeGroupDefinition.o] Error 1
gmake[2]: Leaving directory `/data1/rui/xerces-c-src_2_5_0/src/xercesc/framework/psvi'
gmake[1]: *** [psvi] Error 2
gmake[1]: Leaving directory `/data1/rui/xerces-c-src_2_5_0/src/xercesc/framework'

Regards,
rui
19 REPLIES 19
Dennis Handly
Acclaimed Contributor

Re: xerces build using gnu g++ error -- forward declaration error.

>XSAttributeGroupDefinition.cpp:122: error: invalid use of incomplete type 'struct xercesc_2_5::XMLStringPool'

Has xercesc_2_5::XMLStringPool been defined before line 122? Is this used in a template?
Shinji Teragaito_1
Respected Contributor

Re: xerces build using gnu g++ error -- forward declaration error.

I wonder this error is specific to g++.

When I built Xerces-2.5 with HP ANSI C and aCC compiler on 11.23
around August 2004, I didn't encounter this error.
Dennis Handly
Acclaimed Contributor

Re: xerces build using gnu g++ error -- forward declaration error.

>Shinji: I wonder this error is specific to g++.

You might be able to get the same error with aCC6's +strict option.
Shinji Teragaito_1
Respected Contributor

Re: xerces build using gnu g++ error -- forward declaration error.

Thanks Dennis. +strict option causes a different error:

% aCC +strict -D_HP_UX -DHPaCC -DHPUX11 +Z -c \
-I/home/shinji/oss/xerces-c-src_2_5_0/include \
-AA -w -O -DPROJ_XMLPARSER -DPROJ_XMLUTIL -DPROJ_PARSERS \
-DPROJ_SAX4C -DPROJ_SAX2 -DPROJ_DOM -DPROJ_VALIDATORS \
-DXML_USE_NATIVE_TRANSCODER -DXML_USE_INMEM_MESSAGELOADER \
-DXML_USE_PTHREADS -DXML_USE_NETACCESSOR_SOCKET
-o /home/shinji/oss/xerces-c-src_2_5_0/obj/HPUX/XSAttributeGroupDefinition.o \
XSAttributeGroupDefinition.o-test XSAttributeGroupDefinition.cpp
"/home/shinji/oss/xerces-c-src_2_5_0/include/xercesc/util/NameIdPool.c", line 416: error #2137:
expression must be a modifiable lvalue
fMemoryManager = toAssign.fMemoryManager;

Without +strict option, Xerces-C 2.5.0 build on 11.23 works
successfully with our HP compiler A.06.22 as when I used A.05.57
5 years ago.
Dennis Handly
Acclaimed Contributor

Re: xerces build using gnu g++ error -- forward declaration error.

>Shinji: +strict option causes a different error:
error #2137: expression must be a modifiable lvalue

Where is the caret pointing? To the LHS or which of the tokens on the RHS? What are the types of each?

Basically it says the source is illegal and may be related to the incomplete class that g++ gave. The source has to be reordered and xercesc_2_5::XMLStringPool must be defined before it is used.
Shinji Teragaito_1
Respected Contributor

Re: xerces build using gnu g++ error -- forward declaration error.

In src/xercesc/util/NameIdPool.hpp:

MemoryManager* const fMemoryManager;

After removing "const" from this line, aCC6 +strict doesn't cause
the #2137 error in XSAttributeGroupDefinition.cpp.

I needed one more changes in util/RefArrayOf.hpp to build successfully
whole of Xerces-C 2.5 source code using aCC6 +strict to prevent
the error #2393 "pointer to incomplete class type is not allowed":

% diff util/RefArrayOf.hpp.orig util/RefArrayOf.hpp
104c104
<
---
> #include
%

NOTE: I was able to build successfully Xerces-C 2.8 and 3.0 using
gcc 4.0.0 and aCC6 +strict respectively without any source code
changes.

Rui, can't you use the newer Xerces-C version, either Xerces-C
2.8 or 3.0 ?
Dennis Handly
Acclaimed Contributor

Re: xerces build using gnu g++ error -- forward declaration error.

>MemoryManager* const fMemoryManager;
>After removing "const" from this line

Hmm, that seems like a useless definition unless it is mutable, initialized in a constructor init list or a cast hammer is used.
Shinji Teragaito_1
Respected Contributor

Re: xerces build using gnu g++ error -- forward declaration error.

Rui,

To build Xerces-C 2.5 using gcc and g++, you have to change some files:

1. Add #include to
- framework/psvi/XSAttributeGroupDefinition.cpp
- framework/psvi/XSModelGroupDefinition.cpp
- framework/psvi/XSNotationDeclaration.cpp

2. Add #include to
- framework/psvi/XSNamespaceItem.hpp

3. Change Makefile.incl you referenced as follows:
< EXTRA_LINK_OPTIONS = -b -Wl,+s -Wl,+b,.
--
> EXTRA_LINK_OPTIONS =

I'm using gcc/gcc 4.0 on 11.23. So I hope the same changes work
for your environment, too !!
uiqbal
Advisor

Re: xerces build using gnu g++ error -- forward declaration error.

Hi all,

Thanks for all the support on this thread, i tried the last option and it works great -- it seems you have to add certain changes into source.

Now afterwards i am generating an archive file using

ar r xerceslib.a *.o

but the thing is when I link to xerces using

g++ -o ../cr_api_test.hp -lstdc++ -lX11 -L. -L../ -Wall -Wno-deprecated -lpthread -lm -lsec -lnsl -lrt -L/usr/X11R6/lib ../crxrdlin/crreadline01.a ../unittest/crunittest001.a ../dwmonitor/crdwmonitor001.a ../dwmonitor/systemmonitor/crsysmon001.a ../common/crcommon01.a ../xerceslib.a


I get lot of messages, a few are given below, all have to do with "unsatisfied symbol". Am I missing some linker flag, also xerces code was compiled using -fPIC flag as the same code would be used for shared library, does it make any difference -- if not where lies the problem???

ld: Unsatisfied symbol "xercesc_2_5::RefStackOf<:domnode>::empty()" in file ../xerceslib.a[DOMDocumentImpl.o]
ld: Unsatisfied symbol "xercesc_2_5::ValueStackOf::size()" in file ../xerceslib.a[IGXMLScanner.o]
ld: Unsatisfied symbol "xercesc_2_5::ArrayJanitor::operator[](int) const" in file ../xerceslib.a[IGXMLScanner2.o]
ld: Unsatisfied symbol "xercesc_2_5::Janitor<:schemaattdef>::reset(xercesc_2_5::SchemaAttDef*)" in file ../xerceslib.a[TraverseSchema.o]
ld: Unsatisfied symbol "xercesc_2_5::ValueHashTableOfEnumerator::~ValueHashTableOfEnumerator()" in file ../xerceslib.a[FieldActivator.o]
ld: Unsatisfied symbol "xercesc_2_5::ValueStackOf<:complextypeinfo>::pop()" in file ../xerceslib.a[SchemaValidator.o]
ld: Unsatisfied symbol "xercesc_2_5::NameIdPoolEnumerator<:dtdelementdecl>::nextElement()" in file ../xerceslib.a[XTemplateSerializer.o]
ld: Unsatisfied symbol "xercesc_2_5::ValueVectorOf<:schemagrammar>::removeAllElements()" in file ../xerceslib.a[GrammarResolver.o]
ld: Unsatisfied symbol "xercesc_2_5::ArrayJanitor::~ArrayJanitor()" in file ../xerceslib.a[DOMRangeImpl.o]
ld: Unsatisfied symbol "xercesc_2_5::ArrayJanitor::~ArrayJanitor()" in file ../xerceslib.a[XMLRangeFactory.o]
ld: Unsatisfied symbol "xercesc_2_5::ArrayJanitor::~ArrayJanitor()" in file ../xerceslib.a[Base64.o]
ld: Unsatisfied symbol "xercesc_2_5::ArrayJanitor::~ArrayJanitor()" in file ../xerceslib.a[HPPlatformUtils.o]
ld: Unsatisfied symbol "xercesc_2_5::ArrayJanitor::~ArrayJanitor()" in file ../xerceslib.a[SchemaValidator.o]


Regards,
RUI