I am trying to compile a project that depends on Xerces XML Parser . The project compiles for Windows without any difficulty, but I had problems compiling it with g ++ in Cygwin.
To use Xerces, I am trying to compile my code with the libxerces-ca static library. But when I do this, I get errors that look like this:
/tmp/cc2QGvMh.o:test.cpp:(.text+0x3a): undefined reference to `xercesc_2_8::DOMImplementationRegistry::getDOMImplementation(unsigned short const*)'
I checked the static library with ar and confirmed that it contains the DOMImplementationRegistry.o file, which defines the function that I am calling.
ar -t libxerces-ca ... DOMImplementationImpl.o DOMImplementationRegistry.o DOMLocatorImpl.o ...
I also extracted the object files from the library and used "nm" to make sure that the function actually being called by me exists:
ar -x libxerces-ca nm --demangle DOMImplementationRegistry.o ... 00000080 T xercesc_2_8::getDOMImplSrcVectorMutex() 00000300 T xercesc_2_8::DOMImplementationRegistry::getDOMImplementation(unsigned short const*) 000002a0 T xercesc_2_8::DOMImplementationRegistry::addSource(xercesc_2_8::DOMImplementationSource*) ...
Since I can compile everything for Windows, but not with g ++, I thought the error might be in the linker order (similar to the problem described in this question ), However, even after changing the linker order, I still get the same compiler error. I tried both
g++ -o test.exe test.cpp -Llib -lxerces-c
and
g++ -o test.exe test.cpp lib/libxerces-ca
Any ideas?
source share