Linker error LNK2001

前端 未结 4 1103
遇见更好的自我
遇见更好的自我 2020-12-10 16:34

When I try to create an object I get a LNK2001 error in Visual Studio, it\'s a problem with the constructor I think since changing the constructor changes the error.

相关标签:
4条回答
  • 2020-12-10 17:01

    What's there looks OK to me. Check other things, like make sure your namespaces are right, or there's not another/conflicting "Customer" definition, etc. Try commenting out large sections of code or reducing your code to a small test case.

    0 讨论(0)
  • 2020-12-10 17:04

    I had the same error. It turned out that one necessary function was commented out. When I uncommented this function, the error disappeared.

    0 讨论(0)
  • 2020-12-10 17:05

    I encountered exact same problem. This is how I fixed:

    Use #include<string> instead of #include "string.h" in the file calling Customer constructor.

    0 讨论(0)
  • 2020-12-10 17:11

    If you have linking error then syntactically your code is OK otherwise you'll get compiler errors.

    What you should check(or add) is path in Dependencies property of the project that uses Customer class. In VS you can find it "Project Properties->Configuration Properties->Linker->Input->Additional Dependencies". Seems that linker can't find the external library with Customer implementation. You can successfully compile your project cause all #include are correct but you fail on the stage of linking just because of dependencies.

    0 讨论(0)
提交回复
热议问题