问题
I am facing linker error for a XERCES function while upgrading it from 2.6 to 2.8
unresolved external symbol (?resolveEntity@HandlerBase@xercesc_2_8@@UAEPAVInputSource@2@QBG0@Z)
I checked the xerces-c_2.8.lib and found that name lib is bit different that the one in my .obj file It is as shown
?resolveEntity@HandlerBase@xercesc_2_8@@UAEPAVInputSource@2@QB_W0@Z
So I understand that linker wont find the match and throw error.
But I am unable to understand why my .obj file contains different signature.
code is including correct header files and lib from still incorrect name.
Any help would be appreciated.
回答1:
You can use the undname.exe utility to recover the original C++ declaration.
?resolveEntity@HandlerBase@xercesc_2_8@@UAEPAVInputSource@2@QBG0@Z converts to:
virtual class xercesc_2_8::InputSource *
__thiscall xercesc_2_8::HandlerBase::resolveEntity(
unsigned short const * const,
unsigned short const * const)
?resolveEntity@HandlerBase@xercesc_2_8@@UAEPAVInputSource@2@QB_W0@Z converts to:
virtual class xercesc_2_8::InputSource *
__thiscall xercesc_2_8::HandlerBase::resolveEntity(
wchar_t const * const,
wchar_t const * const)
Note the differences in the argument types, unsigned short
vs wchar_t
. For some reason, your compiler is not recognizing the wchar_t type. That could be because you have a very old compiler. Or it can be an option set wrong, on msvc it is C/C++, Language, "Treat wchar_t as Built-in type". Or you've got a macro that hacks the string type to unsigned short.
回答2:
C++ allows function overloading so the parameters to a function are recorded in the name mangling. you might be trying to call the function with different parameter types than what the DLL expects.
Make sure that your header file matches the version of your DLL.
来源:https://stackoverflow.com/questions/12640139/unresolved-external-symbol-due-to-name-mangling