LNK2001
Visual C++ Programming Language
Severity: ModerateWhat Does This Error Mean?
LNK2001 means the linker encountered a symbol that has no definition anywhere in the linked objects or libraries. It is closely related to LNK2019 and the two usually appear together. LNK2001 is often a cascade: one missing library causes many symbols to be unresolved, each generating its own LNK2001. Fix the LNK2019 errors first — LNK2001 errors usually clear up automatically.
Affected Models
- Visual Studio 2015–2022
- MSVC Linker (link.exe)
Common Causes
- Same root causes as LNK2019 — missing .lib, missing .cpp, or undefined function body
- Abstract virtual function declared but not implemented in a derived class
- A static class member is declared in the header but never defined in a .cpp file
- Template function specialisation is declared but not instantiated
- Mismatch between Debug and Release library variants — linking a Debug .lib in a Release build
How to Fix It
-
Fix LNK2019 errors first. LNK2001 is almost always a cascade from a root LNK2019 — resolving the primary missing symbol clears the secondary ones.
Build the project, go to the first LNK2019 in the error list, and fix it. Recompile — if several LNK2001 errors also disappear, they were downstream of that one root cause.
-
Check static member variables. A static data member declared in a class header must also be defined in exactly one .cpp file.
In the header: static int count; In the .cpp: int MyClass::count = 0; Omitting the .cpp definition causes LNK2001 for that member.
-
Check that Debug builds link Debug libraries and Release builds link Release libraries. Mixing them causes LNK2001 for the runtime symbols.
In Project Properties > Linker > Input, verify that library names match the active configuration (Debug vs Release). Mixing /MT and /MD runtime library settings between your code and a library also causes this.
Frequently Asked Questions
Can a pure virtual function cause LNK2001?
Yes — if a class has a pure virtual function that you forget to implement in the derived class, the vtable for that class is incomplete and the linker reports LNK2001 for the missing implementation.
I have 50 LNK2001 errors — is my project fundamentally broken?
Probably not — 50 LNK2001 errors usually come from one missing library. Add the required .lib file to Linker > Input > Additional Dependencies, rebuild, and most errors will likely vanish at once.