CppPilot

MSVC build errors > LNK2001

LNK2001: unresolved external symbol

error LNK2001: unresolved external symbol "public: static int Counter::count" (?count@Counter@@2HA)

Like LNK2019, the linker found no definition of a symbol, but here no function references it directly: the reference comes from data, such as a virtual function table or a variable.

Causes and fixes

  1. A static data member is declared but not defined. Define it once in a .cpp file (int Counter::count = 0;), or declare it inline static in C++17.
  2. A virtual function has no definition. Define every virtual function that is not pure, including the destructor. A class whose first virtual function is never defined has no virtual table.
  3. A global variable is only declared extern. Define it, without extern, in exactly one .cpp file.
  4. A library or a source file is missing. The causes of LNK2019 apply too: check that the defining file is in the project and that its library is linked for this configuration and platform.

Fix LNK2001 with CppPilot

CppPilot reads the error, your code, and the project settings Visual Studio evaluates for the active configuration, then explains which of these causes applies. Choose Fix and the AI corrects it; CppPilot rebuilds the project and checks that the error is gone. Every change appears in Visual Studio for your approval.

Let the AI fix it in Visual Studio

CppPilot is a free extension that explains and fixes MSVC build errors with Codex, Claude, or CppPilot Cloud.

Get CppPilot free Get started

Related errors: LNK2019, LNK1120, LNK2038. See all guides.