Microsoft KB Archive/815650

= PRB: LNK1120 Error Gives You the Number of Unresolved Externals =

Article ID: 815650

Article Last Modified on 7/25/2003

-

APPLIES TO


 * Microsoft Visual C++ 6.1

-



SYMPTOMS
When you build a C application or a C++ application, and the linker cannot resolve external symbols, you may receive the following LNK1120 linker error message:

fatal error LNK1120:  unresolved externals

where  is the number of external symbols that the linker cannot resolve.



RESOLUTION
To resolve the LNK1120 errors, use the following /LIBPATH option: /LIBPATH:dir where  specifies a path that the linker searches before it searches the path that is specified in the LIB environment variable. For more information, visit the following Microsoft Developer Network (MSDN) Web site:

Visual C++ Linker Options: /LIBPATH (Additional Libpath)

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore/html/_core_.2f.LIBPATH.asp



STATUS
This behavior is by design.



MORE INFORMATION
For more information about the conditions that cause unresolved external symbols, visit the following MSDN Web site:

Linker Tools Error LNK2001

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore/html/LNK2001.asp

The symbols that the linker cannot resolve are described with the LNK2001 error message. The LNK2001 error message comes before the LNK1120 error message. You receive the LNK2001 error message for each unresolved external symbol.

Steps to Reproduce the Behavior
  Paste the following code in Notepad, and then save the file: //The prototypes of functions fun1, fun2 and fun3 void fun1(void); void fun2(void); void fun3(void);

// This is the entry point for this application int main(void) {   fun1; fun2; fun3;

return 0; }   Use the following to compile the application: cl /c  where  is the name of the file that you created and saved in step 1.

Note: To compile the program in Microsoft Visual Studio .NET, use the Microsoft Visual Studio .NET command prompt.

To compile the program in Microsoft Visual Studio 6.0 and earlier, run vcvars32.bat from the command prompt.   Link the object file as follows: Link  

The following linker errors appear at the command prompt:

error LNK2001: unresolved external symbol &quot;void __cdecl fun3(void)&quot; (?fun3@@$$FYAXXZ)

error LNK2001: unresolved external symbol &quot;void __cdecl fun2(void)&quot; (?fun2@@$$FYAXXZ)

error LNK2001: unresolved external symbol &quot;void __cdecl fun1(void)&quot; (?fun1@@$$FYAXXZ)

fatal error LNK1120: 3 unresolved externals

Notice that the LNK1120 error message gives you the number of unresolved external symbols that the linker found.

Keywords: kberrmsg kbprb KB815650

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.