FOR9204006: This Program Requires MS Windows, L2025, L2029

ID Number: Q84323

5.10

WINDOWS

buglist5.10

Summary:

PROBLEM ID: FOR9204006

SYMPTOMS

Attempting to run a Windows executable generated by the Microsoft

FORTRAN version 5.1 compiler may generate the following error

message when executed from MS-DOS:

"This program requires Microsoft Windows"

If the program is run from within Windows, an MS-DOS session may be

opened, the same message displayed, and the MS-DOS session closed--

returning to Windows without executing the program.

CAUSE

This problem may happen if either of the following errors occurs

during the link stage:

L2025: Multiply Defined Symbol

L2029: Unresolved External

If either one of these errors occurs, the linker sets an error bit in

the header of the executable file. This error bit warns the loader

that the executable file contains errors. The Windows loader reacts

to the bit by assuming that the executable is an MS-DOS executable,

and starts an MS-DOS session. Because the executable is actually a

Windows program, the MS-DOS loader correctly flashes the message

"This program requires Microsoft Windows."

If an MS-DOS executable is created with the L2025 or L2029 error

generated during the link stage, the MS-DOS loader will not reject

execution of the MS-DOS program with this error bit turned on.

However, running an MS-DOS application with unresolved externals

may generate incorrect results or hang the system. Under OS/2, a

general protection fault (GP fault) may be generated if the program

tries to access restricted memory locations.

RESOLUTION

If it is impossible or undesirable to correct the link error, the

error bit may be manually reset by using the EXEHDR utility with

the /r option. The complete syntax for doing this is:

EXEHDR /r <exename>

Note that exename is the name of the executable file you want to

reset the error bit in. It is advised to correct the problem during

the link stage. If the program is run after the error bit is reset,

the program may run successfully, generate incorrect results, hang

the system, or generate an unrecoverable application error (UAE).

STATUS

The Windows 3.0 loader fails to interpret the setting of the error

bit as an invalid or incorrectly formed executable. Instead, the

Windows loader assumes the executable is an MS-DOS executable, and

starts an MS-DOS session to run the program.

The Windows 3.1 loader interprets the setting of this error bit in

the same manner. Running the same executable under Windows 3.1

generates the same error message.

More Information:

The following FORTRAN code reproduces the problem:

Sample Code

-----------

This is the source code for the SAMPLE.FOR file:

PROGRAM Sample_Test

PRINT *, 'FORTRAN Test'

GOTO 20

CALL MySub (123) ! MySub is unresolved at link time

20 CONTINUE

END

Project Makefile

----------------

ALL : Sample.EXE

Sample.EXE : Sample.OBJ

Link Sample.OBJ,, nul, /NOD LLIBFEW.LIB, FL.DEF

Sample.OBJ : Sample.FOR

FL /c /MW Sample.FOR

Additional reference words: 5.10 S_C H_FORTRAN