C++ / Documentation search
Find the error. Find the next step.
Search by diagnostic code, copied message, or symptom. Filter by content and project system.
205 results
Browse documentation →LNK2005: A .cpp file is included.
#include "util.cpp" compiles that file twice. Include its header instead.
LNK2005: A function is defined in a header without inline .
Mark it inline , or keep only its declaration in the header and move its body to a .cpp file. Member functions defined inside the class are already inline.
LNK2005: A variable is defined in a header.
Every .cpp file that includes the header defines it again. Declare it extern int counter; in the header and define it in one .cpp file, or make it inline int counter = 0; in C++17.
LNK2005: Runtime library symbols are defined twice.
Symbols already defined in LIBCMT.lib or MSVCRT.lib mean that libraries built with /MT and /MD are mixed: use the same runtime everywhere, as for LNK2038 .
LNK2005: Two libraries define the same symbol.
Link only one of them, or rename the symbol in the code you control.
LNK2019: 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 .
LNK2019: 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.
LNK2019: 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.
LNK2019: 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.
LNK2019: 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.
LNK2019: 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.
LNK2019: 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.
LNK2019: The library was built for another platform.
Link the x64 library in x64 builds and the x86 library in Win32 builds.
LNK2026: A library was built by an old compiler.
Rebuild the library with the current toolset, or get a recent build of it.
LNK2026: An assembly file is assembled without /safeseh .
Set Microsoft Macro Assembler > Advanced > Use Safe Exception Handlers to Yes.
LNK2026: The library cannot be rebuilt.
Set Linker > Advanced > Image Has Safe Exception Handlers to No (/SAFESEH:NO) , for Win32 only. This removes a protection, so prefer rebuilding.
LNK2038: A Release library is linked into a Debug build.
A mismatch on _ITERATOR_DEBUG_LEVEL (0 against 2) means that Debug and Release code are mixed: link the Debug version of the library in Debug builds.
LNK2038: A prebuilt third-party library uses another runtime.
Use the variant built for your runtime, or rebuild it with your settings, for example with the matching vcpkg triplet.
LNK2038: A single file overrides the project.
A .cpp file can have its own Runtime Library setting. Remove the override in its properties so it inherits the project's.
LNK2038: Projects use different runtime libraries.
Set the same C/C++ > Code Generation > Runtime Library in every project of the program: /MD everywhere, or /MT everywhere, with /MDd or /MTd in Debug.