error LNK2001: unresolved external symbol

我怕爱的太早我们不能终老 提交于 2019-12-10 17:37:29

问题


I am converting my project from vc6 to VS 2010.When I compile my project i get error as below for may .lib inputs. I have added all these lib in the Linker-> Input-> Additional Dependencies, also provided the path of these .lib files in Link->General->Additional Library directories. Any tip on this will be very helpful.

lb0.lib(ob0.obj) :error LNK2001: unresolved external symbol "void __stdcall SetLastExP(class ExceptionClass *)" (?SetLastExP@@YGXPAVExceptionClass@@@Z)
lb1.lib(ob1.obj) : error LNK2001: unresolved external symbol "void __stdcall SetLastExP(class ExceptionClass *)" (?SetLastExP@@YGXPAVExceptionClass@@@Z)
lb2.lib(ob2.obj) : error LNK2001: unresolved external symbol "void __stdcall SetLastExP(class ExceptionClass *)" (?SetLastExP@@YGXPAVExceptionClass@@@Z)
lb3.lib(ob3.obj) : error LNK2001: unresolved external symbol "void __stdcall SetLastExP(class ExceptionClass *)" (?SetLastExP@@YGXPAVExceptionClass@@@Z)
lb3.lib(ob4.obj) : error LNK2001: unresolved external symbol "void __stdcall SetLastExP(class ExceptionClass *)" (?SetLastExP@@YGXPAVExceptionClass@@@Z)
lb3.lib(ob5.obj) : error LNK2001: unresolved external symbol "void __stdcall SetLastExP(class ExceptionClass *)" (?SetLastExP@@YGXPAVExceptionClass@@@Z)
lb4.lib(0b6.obj) : error LNK2001: unresolved external symbol "void __stdcall SetLastExP(class ExceptionClass *)" (?SetLastExP@@YGXPAVExceptionClass@@@Z)

Thanks


回答1:


You need to identify where the SetLastExP() function is defined.

  • Check that the library that implements SetLastExP is linked.
  • Get the .obj file and check with dumpbin if it implements in the decoration that you expect.

    dumpbin /symbols foo.obj | find "External" | find "SetLastExP"
    
  • Compare the decoration you see with the decoration you have in the Linker error message.

Probably the function is defined as extern "C" while your header file doesn't reflect this.




回答2:


Sometimes, if you have different Character sets (Configuration properties -> general) in your subprojects, Visual Studio shows this kind of error:

error LNK2001: unresolved external symbol" with an *.obj


来源:https://stackoverflow.com/questions/5016491/error-lnk2001-unresolved-external-symbol

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