The C++ programming language has become one of the most popular general purpose programming languages taught in schools and used in industry. Its ability to allow programmers to create object oriented programs and tie in to low level constructs, has made it one of the most powerful languages available to developers over the past several decades. An error that can be encountered while building C++ projects is the “Error Lnk2019,” which is displayed when an unresolved external symbol is referenced in a function. In order to resolve the error, a definition of the offending symbol has to be made or the offending code statement removed.

How Does the C++ Linker Work?

The C++ linker was created in order to maintain backwards compatibility with COBOL and FORTRAN as well as to hold meta information regarding the code being compiled. The meta information is required because in the early days of the C programming language, computers did not have enough memory to compile all programs. As a result, the program’s text was distributed across different files in order to save memory through pre-processing directives that the #include statement in C or C++ indicate. These translated units could later be linked to the program in order to create an executable program. In order to ensure that no conflict was created due to multiple definitions of the same expression, the “One Definition Rule” was created to ensure that all identifiers with external linkages are original and have a single translation unit that refer to them. As a result, the C++ linker only handles symbols that relate to identifiers.

What Programming Errors Cause Error LNK2019?

The LNK2019 error may be displayed in a wide range of cases. These cases include: 1) when the user declares but fails to define a static data member in code, 2) the declaration of a symbol with a spelling mistake that causes results in the definition of the symbol to be unknown, 3) a function that the number uses or type of parameters not matching the function definition, 4) the calling convention differs between the function definition and its actual use, and 5) symbol definitions being located in a file that was compiled as a C application and these symbols are then declared in a C++ file without the appropriate extern “C” modifier. If using a traditional compiler, the LNK2019 error may also be displayed as a result of Visual Studio .NET 2003 or 2005 conformance work.