L2022, L2029 Errors Linking Application with a .DEF File (79155)



The information in this article applies to:

  • Microsoft LINK for MS-DOS 5.0x
  • Microsoft LINK for MS-DOS 5.1x
  • Microsoft LINK for MS-DOS 5.2
  • Microsoft LINK for MS-DOS 5.3x
  • Microsoft LINK for MS-DOS 5.5
  • Microsoft LINK for MS-DOS 5.6
  • Microsoft LINK for OS/2 5.0x
  • Microsoft LINK for OS/2 5.1
  • Microsoft LINK for OS/2 5.11
  • Microsoft LINK for OS/2 5.13
  • Microsoft LINK for OS/2 5.15

This article was previously published under Q79155

SYMPTOMS

An attempt to link an application fails and Microsoft LINK generates the following messages
error L2022: <name> (alias <internalname>): export undefined
error L2029: <name>: unresolved external

CAUSE

A function name specified in the EXPORTS section of an application's module definition (.DEF) file does not match the actual function name.

RESOLUTION

Modify the function name in the .DEF file to match the name of the function in the code.

MORE INFORMATION

The text below presents two situation in which the errors above occur when Microsoft LINK creates an application for the Microsoft Windows or the OS/2 Presentation Manager operating systems.
  • An application defines a MainWndProc() window procedure with the _pascal attribute. The .DEF file contains an "EXPORTS MainWndProc" statement. The LINK command line includes the /NOI[GNORECASE] option switch. Because MainWndProc() has the _pascal attribute, its true name is MAINWNDPROC(). Further, because the /NOI switch specifies case sensitivity, MainWndProc() and MAINWNDPROC() are not equivalent and the exported function name is not defined.

    To work around this situation, either remove /NOI from the linker command line or modify the .DEF file to specify the function name in upper-case letters.
  • An application defines a ClientWndProc() procedure with the _cdecl attribute. The .DEF file contains an "EXPORTS ClientWndProc" statement. Because ClientWndProc() has the _cdecl attribute, its true name is _ClientWndProc(). ClientWndProc() and _ClientWndProc() are not equivalent and the export is undefined.

    To work around this situation, modify the .DEF file to prepend the procedure name with an underscore. Be sure to preserve the case of the function name in the file.

Modification Type:MajorLast Reviewed:10/23/2003
Keywords:kb16bitonly KB79155