CppPilot

C++ / Documentation search

Find the error. Find the next step.

Search by diagnostic code, copied message, or symptom. Filter by content and project system.

  1. Examples and diagramsMSBuild + CMake

    LNK2005: A .cpp file is included.

    #include "util.cpp" compiles that file twice. Include its header instead.

  2. Examples and diagramsMSBuild + CMake

    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.

  3. Examples and diagramsMSBuild + CMake

    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.

  4. Examples and diagramsMSBuild + CMake

    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 .

  5. Examples and diagramsMSBuild + CMake

    LNK2005: Two libraries define the same symbol.

    Link only one of them, or rename the symbol in the code you control.

  6. Examples and diagramsMSBuild + CMake

    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 .

  7. Examples and diagramsMSBuild + CMake

    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.

  8. Examples and diagramsMSBuild + CMake

    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.

  9. Examples and diagramsMSBuild + CMake

    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.

  10. Examples and diagramsMSBuild + CMake

    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.

  11. Examples and diagramsMSBuild + CMake

    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.

  12. Examples and diagramsMSBuild + CMake

    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.

  13. Examples and diagramsMSBuild + CMake

    LNK2019: The library was built for another platform.

    Link the x64 library in x64 builds and the x86 library in Win32 builds.

  14. Examples and diagramsMSBuild + CMake

    LNK2026: A library was built by an old compiler.

    Rebuild the library with the current toolset, or get a recent build of it.

  15. Examples and diagramsMSBuild + CMake

    LNK2026: An assembly file is assembled without /safeseh .

    Set Microsoft Macro Assembler > Advanced > Use Safe Exception Handlers to Yes.

  16. Examples and diagramsMSBuild + CMake

    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.

  17. Examples and diagramsMSBuild + CMake

    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.

  18. Examples and diagramsMSBuild + CMake

    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.

  19. Examples and diagramsMSBuild + CMake

    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.

  20. Examples and diagramsMSBuild + CMake

    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.