2

I am new to Xercesc. I have included the xerces static lib xerces-c_static_3D.lib in my Project properties->linker additional libraries. Everything else using xerces works fine but when I add this line,

XMLCh* paramStr = XMLString::transcode("param");

I am getting the error below. Please let me know why is this happening?

LNK2001: unresolved external symbol "__declspec(dllimport) public: static unsigned short * __cdecl xercesc_3_1::XMLString::transcode(char const * const,class xercesc_3_1::MemoryManager * const)" (__imp_?transcode@XMLString@xercesc_3_1@@SAPAGQBDQAVMemoryManager@2@@Z)

3>a.lib(MetaFileReader.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: static void __cdecl xercesc_3_1::XMLString::release(unsigned short * *,class xercesc_3_1::MemoryManager * const)" (__imp_?release@XMLString@xercesc_3_1@@SAXPAPAGQAVMemoryManager@2@@Z)

3>a.lib(MetaFileReader.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: static char * __cdecl xercesc_3_1::XMLString::transcode(unsigned short const * const,class xercesc_3_1::MemoryManager * const)" (__imp_?transcode@XMLString@xercesc_3_1@@SAPADQBGQAVMemoryManager@2@@Z)

1 Answer 1

3

IIRC, you need to match some preprocessor flag when you build the Xercesc library with your project setting Treat wchar_t as built-in type. Have a look at the definition of XMLCh in the Xercesc headers to figure out which preprocessor flag. Make sure that your projects that link against the Xercesc library use the same project setting.

Sign up to request clarification or add additional context in comments.

3 Comments

cool thanks!! that worked. I set the Treat wchar_t as built-in type to Yes.
If you still remember this issue, what specifically worked? There is an XMLChar.hpp header. Is that the header file that was meant?
I understand now. There is some history behind wchar_t as a built in type. It is supposed to be but some older compilers defined it as a typedef. In my case I was rebuilding apache_santuario and linking with xerces and encountered some old instructions telling me to set the flag to no so that it is treated as a typedef. This results in a linker error because it is looking for function declarations using unsigned short* instead of wchar_t*. When linking to a xercses lib built by someone else you'd have to have info about how they built it or use trial and error by toggling that flag.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.