error LNK2001: unresolved external symbol

21.2k Views Asked by At

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

2

There are 2 best solutions below

1
On BEST ANSWER

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.

0
On

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