PRB: Linker Error L2041: "Stack Plus Data Exceeds 64K"

Last reviewed: July 17, 1997
Article ID: Q50130
3.65 3.69 4.x 5.0x 5.1x 5.2x 5.3x 5.50 5.60 | 5.0x 5.10 5.11 5.13 5.15
MS-DOS                                      | OS/2
kbtool kberrmsg kberrmgs kbprb

The information in this article applies to:

  • Microsoft LINK for MS-DOS, versions 3.65, 3.69, 4.x, 5.0x, 5.1x, 5.2x, 5.3x, 5.5, and 5.6
  • Microsoft LINK for OS/2, versions 5.0x, 5.1, 5.11, 5.13, and 5.15

SYMPTOMS

An attempt to link an application fails and Microsoft LINK generates the following message:

   L2041 stack plus data exceeds 64K

CAUSE

The application has more than 64K of stack and data to put into DGROUP (the default data segment).

RESOLUTION

To address this situation, perform one or more of the following three steps:

  • Reduce the stack size for the application.
  • Compile the application in the compact, large, or huge memory model.
  • Use the /Gt compiler option switch or the FAR keyword to remove data from DGROUP and place it into another data segment.

MORE INFORMATION

Even though a nonfatal error indicates a problem in the executable file, LINK produces the executable file, unless linking with the /ONERROR:NOEXE linker switch. /ONERROR:NOEXE is available with Microsoft C/C++ 7.0, and Visual C++ for Windows versions 1.0 and 1.5. Each non- fatal error message has the following format:

   location : error L2xxx: messagetext

In a nonfatal error message, the "location" field names the input file associated with the error or "LINK" if there is no input file. If the input file is an object module or library file and it has a module name, the module name is also given, enclosed in parentheses.

REFERENCES

For more information on error L2041, see one of the following references:

  • "Linker Error Messages" (section D.4, page 374) in the "Microsoft QuickC Compiler for IBM Personal Computers and Compatibles Programmer's Guide"
  • The ERRMSG.DOC file on Compiler disk 1 for Microsoft C version 5.1 and on the Setup disk for Microsoft C version 5.0
  • The README.DOC file on disk 1 for Microsoft Macro Assembler (MASM) version 5.1
  • The CVREADME.DOC file on the CodeView for MS-DOS disk for Microsoft FORTRAN version 4.1
  • The online help for Microsoft C version 6.0, MASM version 6.0, and Visual C++ for Windows versions 1.0 and 1.5
  • The "Comprehensive Index and Errors Reference" for Microsoft C/C++ version 7.0, page 503


Additional reference words: 3.65 3.69 4.06 4.07 4.10 5.01.20 5.01.21
KBCategory: kbtool kberrmsg kberrmsg kbprb
KBSubcategory: LinkIss
Keywords : kb16bitonly LinkIss kberrmsg kbprb kbtool
Version : 3.65 3.69 4.x 5.0x 5.1x 5.2x 5.3
Platform : MS-DOS OS/2


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 17, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.