c++ – Linker error LNK2001

c++ – Linker error LNK2001

If you have linking error then syntactically your code is OK otherwise youll 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 cant 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.

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

c++ – Linker error LNK2001

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

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

Leave a Reply

Your email address will not be published.