[xsd-users] Compile and link errors on Windows
Russ Loucks
rjl at third-monday.com
Mon Jan 3 12:30:29 EST 2011
On 12/28/2010 12:11 PM, Russ Loucks wrote:
> I have a small project that works on Linux (2.6.34), Mac (Snow
> Leopard) and I'm now porting it to Windows (Vista).
>
> Since the project is rather portable, I'm using GNU make to build
> everything, including the XSD structure (schema to source files,
> source files to object files, then to dynamic library).
>
> I know there's some foo defined in the 'Using XSD with MS VS'
> (Creating a DLL) online page, but I'm still having problems....
> Here's a snapshot of what is happening:
>
> The xerces-c library I'm using is the 32-bit version.
>
> 1) I create a prolog file with the following text (exports.h):
>
> #ifdef XSD_EXPORTS
> #define XSD_SYMBOL_DECL __declspec(dllexport)
> #else
> #define XSD_SYMBOL_DECL __declspec(dllimport)
> #endif
>
> 2) I include the contents of this file into the generated .h files, as
> follows:
>
> C:/Programs/xsd-3.3.0/bin/xsd cxx-tree --generate-serialization \
> --show-sloc --generate-polymorphic --output-dir src/xsd
> --hxx-suffix .h \
> --cxx-suffix .cpp --generate-ostream --generate-inline \
> --extern-xml-schema xmlSchema.h --hxx-prologue-fi le
> src/xsd/export.h \
> resource.xsd/channelListType.xsd resource.xsd/dataElementType.xsd \
> resource.xsd/dataSourceType.xsd \
> . . . .
>
> I verified the .h files do, indeed, include the contents of that
> prolog file.
>
> However, I'm not sure what symbols need to be defined for compiles...
>
> 3) Compile line and warnings:
>
> g++ -IC:/Programs/xsd-3.3.0/libxsd -IC:/Programs/xerces-c-3.1.1/include \
> -DXSD_EXPORTS -c src/xsd/channelListType.cpp -o
> build/xsd/channelListType.o
>
> In file included from
> C:/Programs/xerces-c-3.1.1/include/xercesc/validators/datatype/DatatypeValidator.hpp:27,
>
> from
> C:/Programs/xerces-c-3.1.1/include/xercesc/framework/XMLAttr.hpp:28,
> from
> C:/Programs/xerces-c-3.1.1/include/xercesc/framework/XMLElementDecl.hpp:25,
> from
> C:/Programs/xerces-c-3.1.1/include/xercesc/validators/common/Grammar.hpp:27,
>
> from
> C:/Programs/xerces-c-3.1.1/include/xercesc/dom/DOMLSParser.hpp:29,
> from
> C:/Programs/xsd-3.3.0/libxsd/xsd/cxx/xml/dom/parsing-source.txx:7,
> from
> C:/Programs/xsd-3.3.0/libxsd/xsd/cxx/xml/dom/parsing-source.hxx:136,
> from src/xsd/channelListType.cpp:43:
> C:/Programs/xerces-c-3.1.1/include/xercesc/util/KVStringPair.hpp:178:
> warning: 'void xercesc_3_1::KVStringPair::setKey(c onst XMLCh*,
> XMLSize_t)' defined locally after being referenced with dllimport linkage
> C:/Programs/xerces-c-3.1.1/include/xercesc/util/KVStringPair.hpp:192:
> warning: 'void xercesc_3_1::KVStringPair::setValue (const XMLCh*,
> XMLSize_t)' defined locally after being referenced with dllimport linkage
>
>
> 4) Linking all of this (command line and errors):
>
> g++ -shared -o lib/libxsd.dll -LC:/Programs/xerces-c-3.1.1/lib
> -lxerces-c_3 \
> build/xsd/channelListType.o build/xsd/dataEl ementType.o \
> build/xsd/dataSourceType.o
> . . . .
>
> build/xsd/channelListType.o:channelListType.cpp:(.text$_ZN3xsd3cxx3xml3dom5clearIcEEvRN11xercesc_3_110DOMElementE[void
> x sd::cxx::xml::dom::clear<char>(xercesc_3_1::DOMElement&)]+0x1a2):
> undefined reference to `__imp___ZN11xercesc_3_16XMLUni 14fgXMLNSURINameE'
>
> build/xsd/channelListType.o:channelListType.cpp:(.text$_ZN3xsd3cxx3xml3dom5clearIcEEvRN11xercesc_3_110DOMElementE[void
> x sd::cxx::xml::dom::clear<char>(xercesc_3_1::DOMElement&)]+0x1bf):
> undefined reference to `__imp___ZN11xercesc_3_113Schem
> aSymbols9fgURI_XSIE'
>
> build/xsd/channelListType.o:channelListType.cpp:(.text$_ZN3xsd3cxx3xml3dom5clearIcEEvRN11xercesc_3_110DOMElementE[void
> x sd::cxx::xml::dom::clear<char>(xercesc_3_1::DOMElement&)]+0x1f6):
> undefined reference to `__imp___ZN11xercesc_3_113Schem
> aSymbols21fgXSI_SCHEMALOCACTIONE'
>
> . . . .
>
> Is this a 32-bit vs. 64 bit issue?
>
> Thanks for you help.
> r
>
Please note I get the exact same errors if I try to build n compile the
examples, as well. Here's the 'make' line I use (in a Cygwin shell).
This command is suggested in the README-CYGWIN.txt file in the distribution.
$ make CPPFLAGS="-Ic:/Programs/xerces-c-3.1.1/include"
LDFLAGS="-Lc:/programs/xerces-c-3.1.1/lib"
I know it looks like I'm not specifying the Xerces library correctly,
however, if I mistype, for example, the location of the Xerces library,
I get the following error:
$ make CPPFLAGS="-Ic:/Programs/xerces-c-3.1.1/include"
LDFLAGS="-Lc:/xxxxx/xerces-c-3.1.1/lib"
g++ -W -Wall -O3 -Lc:/xxxxx/xerces-c-3.1.1/lib -o driver driver.o
hello.o -lxerces-c_3
/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/bin/ld:
cannot find -lxerces-c_3
collect2: ld returned 1 exit status
make: *** [driver] Error 1
Ideas?
More information about the xsd-users
mailing list