Lahey/Fujitsu Fortran

Building Fortran DLLs

When you create a Fortran DLL, you must indicate the procedures that you want to export from the DLL with the DLL_EXPORT attribute. The procedures may be subroutines or functions. When mixing languages, the function results must be of type default INTEGER, REAL, or LOGICAL. The case of the name as it appears in the DLL_EXPORT and DLL_IMPORT statements is preserved for external resolution except when the -ml lf90 option is used; within the Fortran code the case is ignored, i.e., Foo is the same as FOO. Note that the compiler allows you to build your DLL from multiple .OBJ files.

Example code

function half(x) integer, dll_export :: half ! name is case-sensitive integer :: x half = x/2 end

The code must be compiled using one of the options shown in See -ML Options. When the -dll option specified, a DLL is created and a Microsoft-compatible import library is generated.

Example build command

lf95 -dll -win -ml msvc half.f90

The above command creates the files half.dll and half.lib which are compatible with Microsoft Visual C.