You receive "L2029" and "LNK2001" error messages when an attempt to link an application fails (66775)



The information in this article applies to:

  • The Linker (LINK.EXE), when used with:
    • Microsoft Visual C++ for Windows, 16-bit edition 1.0
    • Microsoft Visual C++ for Windows, 16-bit edition 1.5
    • Microsoft Visual C++, 32-bit Editions 1.0
    • Microsoft Visual C++, 32-bit Editions 2.0
    • Microsoft Visual C++, 32-bit Editions 4.0
    • Microsoft Visual C++, 32-bit Editions 5.0
    • Microsoft Visual C++, 32-bit Editions 6.0
    • Microsoft C for MS-DOS 5.1
    • Microsoft C for MS-DOS 5.1a
    • Microsoft C for MS-DOS 6.0
    • Microsoft C for MS-DOS 6.0a
    • Microsoft C for MS-DOS 6.0ax
    • Microsoft C for OS/2 5.1
    • Microsoft C for OS/2 6.0
    • Microsoft C for OS/2 6.0a
    • Microsoft C/C++ for MS-DOS 7.0
    • Microsoft Visual C++ .NET (2003)
    • Microsoft Visual C++ .NET (2002)

This article was previously published under Q66775
NOTE: Microsoft Visual C++ NET (2002) supported both the managed code model that is provided by the .NET Framework and the unmanaged native Windows code model. The information in this article applies to unmanaged Visual C++ code only.

SYMPTOMS

An attempt to link an application fails and Microsoft LINK generates the following messages.

With Microsoft C/C++ 16-bit compilers:

L2029: unresolved external
With Microsoft C/C++ 32-bit compilers:
LNK2001: unresolved external symbol

CAUSE

The application declares an unsized array at file scope, and does not contain another declaration at file scope that specifies the size for the array.

RESOLUTION

Modify the source code of one of the modules to declare the array with its correct size at file scope.

MORE INFORMATION

Because an unsized array declaration at file scope is considered external, the C compiler cannot determine whether or not the size is omitted intentionally, and the compiler does not generate an error message.

The following sample code demonstrates this situation:

Sample Code

int Array[];

void main(void)
{
   printf("%d.\n", Array);
}
				
To address this situation, create another source file that declares Array to have a size (for example, "int Array[2]"), and compile and link the two modules.

Modification Type:MinorLast Reviewed:1/12/2006
Keywords:kbprb KB66775 kbAudDeveloper