You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xerces.apache.org by John Legato <jl...@helix.nih.gov> on 2007/05/31 13:51:18 UTC

Xerces 2.7.0 linking under Cygwin

We are having some difficulty using Xerces  C 2.7.0 under cygwin 1.5.24. 
We've successfully built
Xerces as a shared library under cygwin. We are using it from a library 
called libsbml
(http://sbml.org/software/libsbml). libsbml also successfully builds; 
however when we attempt to
compile the examples, we get errors regarding undefined symbols:

gcc -Wall -I//home/jlegato/SOSlibWIn/xerces/include -I../../include
-L//home/jlegato/SOSlibWIn/xerces/lib -L../../src -o convertSBML 
convertSBML.c util.c -lxerces-c -l
sbml -lstdc++ -lm
../../src/libsbml.a(SBMLWriter.o): In function 
`_ZN11xercesc_2_710XMLDeleterD1Ev':
//home/jlegato/SOSlibWIn/xerces/include/xercesc/util/PlatformUtils.hpp:847: 
undefined reference to
`xercesc_2_7::XMLUni::fgXercescDefaultLocale'
//home/jlegato/SOSlibWIn/xerces/include/xercesc/util/PlatformUtils.hpp:847: 
undefined reference to
`xercesc_2_7::XMLPlatformUtils::Initialize(char const*, char const*, 
xercesc_2
_7::PanicHandler*, xercesc_2_7::MemoryManager*, bool)'
//home/jlegato/SOSlibWIn/xerces/include/xercesc/util/PlatformUtils.hpp:847: 
undefined reference to
`xercesc_2_7::XMemory::operator new(unsigned int)'
//home/jlegato/SOSlibWIn/xerces/include/xercesc/util/PlatformUtils.hpp:847: 
undefined reference to
`xercesc_2_7::XMemory::operator delete(void*)'
../../src/libsbml.a(SBMLWriter.o): In function 
`_ZN10SBMLWriter13writeToStringERK12SBMLDocument':
//home/jlegato/SOSlibWIn/libsbml-2.3.4/src/sbml/SBMLWriter.cpp:224: 
undefined reference to
`xercesc_2_7::XMLUni::fgXercescDefaultLocale'
//home/jlegato/SOSlibWIn/libsbml-2.3.4/src/sbml/SBMLWriter.cpp:224: 
undefined reference to
`xercesc_2_7::XMLPlatformUtils::Initialize(char const*, char const*, 
xercesc_2_7::Pani
cHandler*, xercesc_2_7::MemoryManager*, bool)'
//home/jlegato/SOSlibWIn/libsbml-2.3.4/src/sbml/SBMLWriter.cpp:226: 
undefined reference to
`xercesc_2_7::XMemory::operator new(unsigned int)'
//home/jlegato/SOSlibWIn/libsbml-2.3.4/src/sbml/SBMLWriter.cpp:226: 
undefined reference to
`xercesc_2_7::XMLPlatformUtils::fgMemoryManager'
//home/jlegato/SOSlibWIn/libsbml-2.3.4/src/sbml/SBMLWriter.cpp:226: 
undefined reference to
`xercesc_2_7::MemBufFormatTarget::MemBufFormatTarget(int, 
xercesc_2_7::MemoryManager*)
'

I did some reading on the cygwin site and found a section regarding dlls, 
that leads me to believe I
need to add the following options when building Xerces under cygwin in 
order to resolve symbols when
other libraries link to it:

"However, if you are building a dll as an export library, you will 
probably want to use the complete
syntax:

gcc -shared -o cyg${module}.dll \
     -Wl,--out-implib=lib${module}.dll.a \
     -Wl,--export-all-symbols \
     -Wl,--enable-auto-import \
     -Wl,--whole-archive ${old_libs} \
     -Wl,--no-whole-archive ${dependency_libs}" from 
http://cygwin.com/cygwin-ug-net/dll.html

I do not see these options in the Xerces C build setup for Cygwin. Are 
they neccessary? If so how do
I go about adding them?

Thanks

John

Re: Xerces 2.7.0 linking under Cygwin

Posted by Boris Kolpackov <bo...@codesynthesis.com>.
Hi John,

John Legato <jl...@helix.nih.gov> writes:

> gcc -Wall -I//home/jlegato/SOSlibWIn/xerces/include -I../../include
> -L//home/jlegato/SOSlibWIn/xerces/lib -L../../src -o convertSBML
> convertSBML.c util.c -lxerces-c -l
> sbml -lstdc++ -lm
> ../../src/libsbml.a(SBMLWriter.o): In function
> `_ZN11xercesc_2_710XMLDeleterD1Ev':
> //home/jlegato/SOSlibWIn/xerces/include/xercesc/util/PlatformUtils.hpp:847:
> undefined reference to
> `xercesc_2_7::XMLUni::fgXercescDefaultLocale'

>From the above it appears that libsbml is build as an archive (.a). In
that case it make be a good idea to put -lxerces-c after it:

-lsbml -lxerces-c -lstdc++ -lm


Also I suggest that you use g++ instead of gcc for linking C++ applications.


hth,
-boris

-- 
Boris Kolpackov
Code Synthesis Tools CC
http://www.codesynthesis.com
Open-Source, Cross-Platform C++ XML Data Binding