Knowledge Base

DLL with PROGRAM Statement Fails to Load

PSS ID Number: 131498

Article Last Modified on 11/2/1999


The information in this article applies to:


This article was previously published under Q131498

SYMPTOMS

If a FORTRAN DLL contains a PROGRAM statement or other main section of code, programs calling the DLL fail to load it; they return an error. The error returned depends on the program.

  • Visual Basic version 3.0 and Microsoft Word version 6.0 give an "Out of memory" error when attempting to call a function or subroutine in the DLL.
  • Microsoft Excel version 5.0 reports "Run time error '48' Error in loading DLL" when attempting to call a function or subroutine in the DLL.
  • A Windows-based application built in C that uses LoadLibrary() to load the DLL returns 0 (System was out of memory, executable file was corrupt, or relocations were invalid).
  • An application that loads the DLL by linking with the DLL import library terminates the application upon loading the DLL. The Visual C++ debugger displays the message "Process 0xXXXX Terminated Normally (240)" if the program is being debugged. If the program is being executed, the program doesn't appear to execute but reports no warnings, errors, or messages. The program does not load and no window is displayed.
  • A Windows-based application built in FORTRAN gives no warnings, errors, or messages. The program does not load and no window is displayed.

CAUSE

A DLL should not have a PROGRAM statement.

STATUS

This behavior is by design.

MORE INFORMATION

Sample Code to Demonstrate Behavior

C  Compile options needed: /Gw /Aw
C
C  DLL functions and subroutines
      SUBROUTINE SubroutineOne()
      ...
      END

      INTEGER*4 FUNCTION FunctionOne()
      ...
      END

C  The code below is not needed for a DLL
      PROGRAM MainProgram
      ...
      END
				

Additional query words: 1.00 1.50 1.51 1.52 5.10

Keywords: KB131498
Technology: kbAudDeveloper kbFORTRAN510DOS kbFortranSearch kbZNotKeyword3