CppPilot

MSVC build errors > LNK2019

LNK2019: unresolved external symbol

error LNK2019: unresolved external symbol "int __cdecl Compute(int)" (?Compute@@YAHH@Z) referenced in function main

The compiler found a declaration of the function or variable, so the code compiled, but the linker found no definition of it in any object file or library it was given. The message names the missing symbol and the function that uses it.

Causes and fixes

  1. The function is declared but never defined. Write its body, or remove the call. A declaration in a header is only a promise that a definition exists somewhere.
  2. The .cpp file that defines it is not part of the project. Add the file to the project in Solution Explorer: a file on disk that is not in the project is never compiled.
  3. The library that defines it is not linked. Add the .lib to Linker > Input > Additional Dependencies and its folder to Linker > General > Additional Library Directories, for every configuration and platform. For a library built in the same solution, add a project reference instead.
  4. The declaration and the definition do not match. Compare the signature: a missing const, a different parameter type, another namespace, or a member function defined without its Class:: prefix declares a different symbol.
  5. C code is called from C++ without extern "C". Wrap the C declarations in extern "C" { } in the header, so that C++ looks for the undecorated name.
  6. A template or an inline function is defined in a .cpp file. Move its definition to the header: it must be visible wherever it is used.
  7. The library was built for another platform. Link the x64 library in x64 builds and the x86 library in Win32 builds.
  8. main or WinMain is missing. An unresolved main referenced in invoke_main means that Linker > System > SubSystem does not match the entry point: Console expects main, Windows expects WinMain.

Fix LNK2019 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: LNK2001, LNK1120, LNK1104, LNK2005. See all guides.