简体   繁体   中英

error LNK2001: unresolved external symbol

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

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.

有时,如果子项目中有不同的字符集( Configuration properties - > general ),Visual Studio会显示以下类型的错误:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM