PRB: L2029: Unresolved External _main in crt0.asm

Last reviewed: December 11, 1995
Article ID: Q49526
The information in this article applies to:
  • Microsoft FORTRAN for MS-DOS and OS/2, versions 4.1, 5.0, and 5.1
  • Microsoft FORTRAN PowerStation for MS-DOS, versions 1.0 and 1.0a
  • Microsoft FORTRAN PowerStation 32 for Windows NT, version 1.0 and 4.0

SYMPTOMS

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

   (dos\crt0.asm) : error L2029: '_main' unresolved external

-or-

   libc.lib(CRT0.OBJ) : warning LNK4516: unresolved external symbol "_main"
   error LNK2120: 1 Undefined Externals

-or-

   libc.lib(CRT0.OBJ) : warning LNK4016: unresolved external symbol "_main"
   error LNK1120: 1 unresolved externals

For FORTRAN PowerStation 32, version 4.0:

   error FOR1768: missing END statement or missing program unit
   (possibly free-form source in fixed-form file)

CAUSE

The compiler or the linker cannot determine the entry point for the program.

RESOLUTION

To address this problem, perform one of the following three steps:

  • Verify that the lines of the FORTRAN source code begin in column seven and that the program has an END statement.
  • Specify the /4Yf compiler option switch to enable free-form source code.
  • Verify that the source file containing the main program is being compiled and linked in.

MORE INFORMATION

The following code example demonstrates this problem. Each line in the example begins in column one. The compiler interprets each line to be a comment and does not issue an error. However, because Microsoft LINK cannot find the END statement, it cannot identify the main program and issues an L2029 error for the unresolved external _main. Compiling this application with the /4Yf option switch corrects this problem.

Sample Code

C Compile options needed: See above

INTEGER*4 I I = 5 WRITE(*, *) I END


Additional reference words: 1.00 4.00 4.10 5.00 5.10 F2830
KBCategory: kbtool kberrmsg kbprb
KBSubcategory: FLIss


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: December 11, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.