unresolved external symbol due to name mangling

荒凉一梦 提交于 2019-12-21 16:57:14

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!