Unable to resolve external symbol "Symbol"
The code references the linker that cannot be found in the library and object files (such as functions, variables or tags).
possible reason
The content of the code request does not exist (for example, the symbol spelling error or using the wrong case). The content error of the code request (uses a mixed version library, some libraries come from a version of the product, while others come from another version).
The error message is followed by a fatal error LNK1120.
specific reason
Code problem
If the LNK2001 diagnostic text report __check_commonlanguageruntime_version is an external symbol that cannot be parsed, see how the LNK2019 understands how to solve the problem. The definition of a member template is exceeded. One restriction of Visual C is that the definition of the member template must be fully located within the closed class. For more information on the LNK2001 and member templates, see Knowledge Base Articles Q239436. Code or Module Definition (.def) The case where the case does not match in the file can cause the LNK2001. For example, when a variable is named VAR1 in a C source file, it is tried to access the variable in VAR1 in another source file. If the item uses the inline line, but in the .cpp file, it is defined in the header file, the LNK2001 will cause the LNK2001. Adding a C function from the C program but does not use extern "C" (which causes the compiler to use C named conventions to cause the LNK2001. Compiler options / TP and / TC make the compiler to compile files into C or C , independent of the file extension. These options will cause a function name to be different from the name you expect. A function or data attempting to reference without an external link will cause the LNK2001. In C , the inline function and const data have internal links unless explicitly specified as extern. The lack of functional or variables can cause the LNK2001. If only function prototypes or extern declarations, the compiler continues to run without any errors, but the linker will not be able to resolve address calls or variable references because no function code or variable space is reserved. Calling parameter types and functions in the parameter type in the function declaration cause the LNK2001. Name modification combines function parameters into the final modified function name. Error The prototypes that cause the compiler to require no function, which will cause the LNK2001. If you have a class implementation and non-class implementation with a function F, please pay attention to the C range resolution rule. When using C , the function prototype is included in the class definition but failed to include the implementation (the implementation of this function of this class) can cause the LNK2001. Trying to call the pure virtual function from the constructor of the abstract base class or the destructive function causes the LNK2001. The pure virtual function is not implemented. Trying to access the static variable from an external file containing static variables to cause the LNK2001. Depending on the definition, the function declared with the Static modifier has a file range. Static variables have the same limitations. Trying to use this function declared outside the function range (local variable) causes the LNK2001. Trying to use C global constants in multiple files can cause the LNK2001. Unlike C, the global constant in C has a Static link. To avoid this limit, Const initialization can be included in the header file and include this header in the .cpp file, or make the variables a very number, then access it using the constant reference. When the release version of the ATL project is generated, the code is required to start the code. To fix, do one of the following:
Remove the _ATL_MIN_CRT from the preprocessor definition list to allow the CRT startup code. For more information, see the General Configuration Settings Properties page. If possible, remove the call to the CRT function that requires the CRT startup code, but uses their Win32 equivalent functions. For example, use lstrcmp to replace strCMP. A known function that requires a CRT startup code is some strings and floating-point functions. Compilation and link problem
The project lacks a reference to the library (.lib) or object (.Obj) file. For more information, see Used as a .lib file for entered by the linker. When the name of the runtime library and the MFC library is included in the object file module, the LNK2001 will cause the LNK2001. These libraries will not be linked to the project if the / nod (/ nodefaultlib) option will be linked to the project unless explicitly contains them. When using Unicode and MFC, if you do not create the entry point of WWINMAINCRTSTARTUP, an external object that cannot be parsed is obtained on _winmain @ 16; please use / entry. See the Unicode programming summary. For more information, see Knowledge Base Articles in MSDN Library. In MSDN Library, click the Search tab, paste the article number or article title in the text box, and then click List the theme. If you search by article number, make sure the "Search Title" option is cleared.
Q125750 "PRB: Error LNK2001: '_WinMain @ 16': Unresolved External Symbol" Q131204 "PRB: Wrong Project Selection Causes LNK2001 on _WinMain @ 16" Q100639 "Unicode Support in the Microsoft Foundation Class Library" Q291952 "PRB: Link Error LNK2001: Unresolved External Symbol _main "will use / MT to compile the libc.lib link in _beginthread, _beneread, _beginthreadex, _endthread, and _endthreadex cause the LNK2001. Links require multi-thread library code (any MFC code or code compiled with / mt) will cause the lnk2001 on _BeginThread, _BeginThreadex, _endthread, and _endthreadex causes LNK2001. For more information, see the following knowledge base articles:
Q126646 "PRB: Error Msg: LNK2001 on __beginthreadex and __endthreadex" Q128641 "INFO: / Mx Compiler Options and the LIBC, LIBCMT, MSVCRT Libs" Q166504 "PRB: MFC and CRT Must Match in debug / release and static / dynamic" with / MD is compiled because all run libraries are now stored in the DLL, so the "FUNC" reference in the source becomes "__imp__func" in the object. If you try to link the static library libc.lib or libcmt.lib, LNK2001 will be obtained on __Imp__func. When you do not have to compile / MD, if you try to link with the MSVCXX.LIB link, it is not always LNK2001, but there may be other problems. The LNK2001 will be caused to the _ERRNO when the code is linked to libcmt.lib with explicit or implicit / ml. The LNK2001 will cause the LNK2001 when the debug version of the application is generated. Similarly, use the / MXD option (/ MLD, / MTD or / MDD) and / or define _debug, and then with the publisher link will bring potential unable to resolve external objects (and other issues). Link publishing mode generation and debug library will also result in similar problems. There is a problem with the Microsoft library version and compiler product version. The new compiler version of the library may contain new symbols not in the earlier version of the library. You may need to change the directory order in the search path, or change them to the current version. The "Tool" | "Options" | "Project" | "VC Directory" dialog box selection, you can change the search order. The "Limited" folder in the Properties Page dialog box of the project may also contain paths that may have expired. This issue may occur when the new SDK is installed (possibly in different locations), but this problem may occur when the search order is updated to point to the new location. Typically, the new SDK's include directory and the path to the lib directory should be placed in front of the default Visual C position. In addition, items containing embedded paths may still point to the old path, which is valid, but new features added to new versions installed to different locations have expired. Between the compiler supplier, there is currently no C naming standard between the different versions of the same compiler. Therefore, the object file compiled with other compilers may not be able to generate the same naming scheme, resulting in errors LNK2001. Mixing the inline and non-inline compilation options on different modules can cause the LNK2001. If the function inline (/ OB1 or / OB2) is turned on when the C library is created, the inline of the corresponding header file describing the function is closed (there is no inline keyword), which will happen. To prevent this problem, use Inline to define the inline function in the header in other files. If you use a #pragma inline_Depth compiler, make sure to set the value set to 2 or more, and ensure that the / OB1 or / OB2 compiler option is used. The LINK Options / Nontry will cause the LNK2001 when creating a pure resource DLL. Use incorrect / subsystem or / entry settings to cause LNK2001. For example, if you write a character-based application (console application) and specify / subsystem: windows, you will get WinmaIn external objects that cannot be parsed. For more information on these options and entry points, see the / subsystem and / entry linker option.
The created project is a managed DLL that contains the Microsoft Intermediate Language Code that is not linked to the local C / C library (such as CRT, ATL or MFC), and you add code from the native C / C library using a static variable. To fix, the project must be converted to a mixed mode. For more information, see Converting C Hosting Extensions from the pure intermediate language to a hybrid mode. Export problem
LNK2001 occurs when the application is transplanted from 16-bit to 32 bits. Current 32-bit module definition (.def) file syntax requires __cdecl, __ stdcall, and __fastcall function column in the Exports section and without undertaking (no decoration). This is different from 16-bit syntax, which must be underlined (modification) when listed in the 16-bit syntax. For more information, see Module Definition File Exports section. Any export listed in the .def file is not found will cause the LNK2001. This may be because the export does not exist, spelling errors, or using C modes (.def files do not use the modified name).
Interpretation of output
If the symbol cannot be resolved, information about functions can be obtained by the following guidelines:
On the X86 platform, the call for the C-compiled name or the EXTERN "C" name in C is:
__cdecl
The function has a prefix of the underscore (_).
__stdcall
The function has a debl line (_) prefix and the @ suffix, and the double word length of the parameter on the stack is sized.
__fastcall
The function has a @ prefix and @ suffix, and the double word length of the parameters on the stack is sized.
Use undname.exe to get the unmifted format of the modified name.
For more information on some of the reasons listed above, see:
Missing function main body or variable name modified this symbol is not a public (function range) variable C global constant function inline problem