- 9 minutes to read
unresolved external symbol 'symbol' referenced in function 'function'
The compiled code for function makes a reference or call to symbol, but the linker can't find the symbol definition in any of the libraries or object files to link.
This error message is followed by fatal error LNK1120, linker error undefined symbol in module asm. To fix error LNK1120, you must fix all LNK2001 and LNK2019 errors first.
There are many ways to get listview dblclick delphi error error. All of them involve a reference to a function or variable that the linker couldn't resolve, or find a definition for. The compiler can identify when a symbol isn't declared, but it can't tell when the symbol isn't defined. That's because the definition may be in a different source file or library. If a symbol is referred to but never defined, the linker generates an unresolved external symbol error.
Here are some common problems that cause LNK2019:
The source file that contains the definition of the symbol isn't compiled
In Visual Studio, make sure the source file that defines the symbol gets compiled as part of your project. Check the intermediate build output directory for a matching .obj file. If the source file isn't compiled, right-click on the file in Solution Explorer and choose Properties to check the properties of the file, linker error undefined symbol in module asm. The Configuration Properties > General page should show an Item Type of C/C++ Compiler. On the command line, make sure the source file that contains the definition is compiled.
The object file or library that contains the definition of the symbol isn't linked
In Visual Studio, make sure the object file or library that contains the symbol definition is linked as part of your project. On the command line, make sure the list of files to link includes the object file or library.
The declaration of the symbol isn't spelled the same as the definition of the symbol
Verify you use the correct spelling and capitalization in both the declaration and the definition, and wherever the symbol is used or called.
A function is used but the type or number of the parameters don't match the function definition
The function declaration must match the definition. Make sure the function call matches the declaration, and that the declaration matches the definition. Code that invokes template functions must also have matching template function declarations that include the same template parameters as the definition. For an example of a template declaration mismatch, see sample LNK2019e.cpp in the Examples section.
A function or variable is declared but not defined
LNK2019 can occur when a declaration exists in a header file, but no matching definition is implemented. For member functions or static data members, linker error undefined symbol in module asm, the implementation must include the class scope selector. For an example, see Missing Function Body or Variable.
The calling convention is different between the function declaration and the function definition
Calling conventions (__cdecl, __stdcall, __fastcall, or __vectorcall) are encoded as part of the decorated name. Make sure the calling convention is the same.
A symbol is defined in a C file, but declared without using extern "C" in a C++ file
Symbols defined in a file that is compiled as C have different decorated names than symbols declared in a C++ file unless you use an extern "C" modifier. Make sure the declaration matches the compilation linkage for each symbol. Similarly, if you define a symbol in a C++ file that will be used by a C program, use in the definition.
A symbol is defined as static and then later referenced outside the file
In C++, unlike C, global constants have linkage. To get around this limitation, you can include the initializations in a header file and include that header in your .cpp files, or you can make the variable non-constant and use a constant reference to access it.
A static member of a class isn't defined
A static class member must have a unique definition, or it will violate the one-definition rule. A static class member that can't be defined inline must be defined in one source file by using its fully qualified name. If it isn't defined at all, the linker generates LNK2019.
A build dependency is only defined as a project dependency in the solution
In earlier versions of Visual Studio, linker error undefined symbol in module asm, this level of dependency was sufficient. However, starting with Visual Studio 2010, Visual Studio requires a project-to-project reference. If your project doesn't have a project-to-project reference, you may receive this linker error. Add a project-to-project reference to fix it.
An entry point isn't defined
The application code must define an appropriate entry point: or for console applications, and or for Windows applications. For more information, see main function and command-line arguments or WinMain function. To use a custom entry point, specify the /ENTRY (Entry-Point Symbol) linker option.
You build a console application by using settings for a Windows application
If the error message is similar to unresolved external symbol WinMain referenced in functionfunction_name, link by using /SUBSYSTEM:CONSOLE instead of /SUBSYSTEM:WINDOWS. For more information about this setting, and for instructions on how to set this property in Visual Studio, see /SUBSYSTEM (Specify Subsystem).
You attempt to link 64-bit libraries to 32-bit code, or 32-bit libraries to 64-bit code
Libraries and object files linked to your code must be compiled for the same architecture as your code. Make sure the libraries your project references are compiled for the same architecture as your project. Make sure the /LIBPATH or Additional Library Directories property points to libraries built for the correct architecture.
You use different compiler options for function inlining in different source files
Using inlined functions defined in .cpp files and mixing function inlining compiler options in different source files can cause LNK2019. For more information, see Function Inlining Problems.
Automatic linker error undefined symbol in module asm scope) variables can only be used in the scope of that function. These variables can't be declared and used in other source files. For an example, see Automatic (Function Scope) Variables.
You call intrinsic functions or pass argument types to intrinsic functions that aren't supported on your target architecture
For example, if you use an AVX2 intrinsic, but don't specify the /ARCH:AVX2 compiler option, the compiler assumes that the intrinsic is an external function. Instead of generating an inline instruction, the compiler generates a call to an external symbol with the same name as the intrinsic. When the linker tries to find the definition of this missing function, it generates LNK2019. Make sure you only use intrinsics and types supported by your target architecture.
You mix code that uses native wchar_t with code that doesn't
C++ language conformance work that was done in Visual Studio 2005 made a native type by default. If not all files have been compiled by using the same /Zc:wchar_t settings, type references may not resolve to compatible types. Make sure types in all library and object files are compatible. Either update from a typedef, or use consistent /Zc:wchar_t settings when you redmine mysql error library issues and vcpkg
If you see this error when you're trying to configure a third-party library as part of linker error undefined symbol in module asm build, consider using vcpkg, a C++ package manager, to install and build the library. vcpkg supports a large and growing list of third-party libraries. It sets all the configuration properties and dependencies required for successful builds as part of your project.
Sometimes it's difficult to tell why the linker can't find a particular symbol definition. Often the problem is backup exec error 1259 you haven't included the code that contains the definition in your build. Or, linker error undefined symbol in module asm, build options have created different decorated names for external symbols. There are several tools and options that can help you diagnose LNK2019 errors.
The /VERBOSE linker option can help you determine which files the linker references. This option can help you verify whether the file that contains the definition of the symbol is included in your build.
The /EXPORTS and /SYMBOLS options of the DUMPBIN utility can help you discover which symbols are defined in your .dll and object or library files. Make sure the exported decorated names match the decorated names the linker searches for.
The UNDNAME utility can show you the equivalent undecorated external symbol for a decorated name.
Here are several examples of code that causes a LNK2019 error, together with information about how to fix the error.
A symbol is declared but not defined
In this example, an external variable is declared but not defined:
Here is another example where a variable and function are declared as but no definition is provided:
Unless and are defined in one of the files included in the build, the linker generates LNK2019. You can fix the errors by including the source code file that contains the definitions as part of the compilation. Alternatively, you can pass .obj files or .lib files that contain the definitions to the linker.
A static data member is declared but not defined
LNK2019 can also occur when a static data member is linker error undefined symbol in module asm but not defined. The following sample generates LNK2019, and shows how to fix it.
Declaration parameters don't match the definition
Code that invokes template functions must have matching template function declarations. Declarations must include the same template parameters as the definition. The following sample generates LNK2019 on a user-defined operator, and shows how to fix it.
Inconsistent wchar_t type definitions
This sample creates a DLL that has an export that useswhich resolves to .
The next sample uses the DLL in the previous sample, and generates LNK2019 because the types and aren't the same.
To fix this error, linker error undefined symbol in module asm, change to oror compile LNK2019g.cpp by using /Zc:wchar_t-.
For more information about possible causes and solutions for LNK2001, see the Stack Overflow question What is an undefined reference/unresolved external symbol error and how do I fix it?.