LF Fortran 95  

C Calling Fortran DLLs

Create the Fortran DLL as described in Building Import Libraries, building with the -ml compile option that matches your C compiler.

To compile your Fortran source for use with Microsoft Visual C++, issue the command:

LF95 source.f90 -win -ml msvc -dll

This command will cause a DLL called source.dll to be created, as well as an import library called source.lib.

To compile your Fortran source for use with Borland C++, issue the command:

LF95 source.f90 -win -ml bc -dll

The user will need to run Borland's IMPLIB.EXE to build the import library compatible with the Borland linker. IMPLIB is distributed with the Borland compiler, and is not a part of LF95.

Once you've created the DLL and generated the import library, use the C language system to link the associated import library (source.lib in the above cases) with your C object code, and be sure the DLL is available on your system path.