Using Intel® Visual Fortran to Create and Build Windows*-Based Applications
Building Dynamic-Link Libraries
When you first create a DLL, create a new project,
and select Fortran Dynamic-Link Library as the project type.
To debug a DLL, you must use a main program that
calls the library routines (or references the data). From the Project Property
Pages dialog box, choose the Debugging category. A dialog box is available for
you to specify the executable for a debug session.
To build the DLL from
the Microsoft integrated development environment (IDE):
A Fortran DLL project is created like any other
project, but you must specify Dynamic-Link Library as the project type.
Add files to your Fortran DLL project. Include
the DLL Fortran source that exports procedures or data as a file in your
If your DLL exports data, consistently specify
the project settings options in the Fortran Data compiler option category for
both the DLL and any image that references the DLL's exported data. In the
Fortran Data compiler option category, specify the appropriate values for
Common Element Alignment (common block data) and Structure Member Alignment
(structures in a module). This sets the
specifies whether padding is needed to ensure that exported data items are
For example, in the case of a common block containing
four-byte variables, you might:
Open the appropriate solution and select the
project in the Solution View.
the Fortran category.
In the Common Element Alignment box, select 4
If you need to specify linker options, use the Linker
category of the Project Property Pages dialog box.
Build your Fortran DLL project.
The IDE automatically selects the correct linker
instructions for loading the proper run-time library routines (located in a DLL
themselves). Your DLL is created as a multithread-enabled library. An import
library (.LIB) is created for use when you link images that reference the DLL.
To build the DLL from the
If you build a DLL from the command line or use a
makefile, you must specify the /dll option. For example, if the Fortran DLL
source code is in the file
the following command line:
ifort /dll f90arr.f90
This command creates:
A DLL named
An import library,
that you must link with applications that call your DLL.
If you also specify
, the file name you specify
is used for a .DLL rather than an .EXE file (the default file extension becomes
selects, as the default, the DLL run-time libraries to support multithreaded
If your DLL will export data, the procedures must
be compiled and linked consistently. Consistently use the same
option for the
DLL export procedure and the application that references (imports) it. The goal
is to specify padding to ensure that exported data items are naturally aligned,
including common block data items and structure element alignment (structures
in a module).
If you need to specify linker options, place them
option on the
ifort command line.
Build the application. For example, if your DLL
exports a common block containing four-byte variables, you might use the
following command line (specify the
ifort /align:commons /dll dllfile.for
automatically selects the correct linker instructions for loading the proper
run-time library routines (located in a DLL themselves). Your DLL is created as
a multithread-enabled library.
The DLL Build Output
When a DLL is built, two library files are typically
An import library (.LIB), which the linker uses
to associate a main program with the DLL.
The .DLL file containing the library's executable
Both files have the same basename as the library
project by default.
For a build from the command line, your library
routines are contained in the file
located in the default directory for your project, unless you specified another
name and location. Your import library file is
located in the default directory for your project.
For a build from the Microsoft* Visual Studio*
integrated development environment, both the library routines and the import
library file are located in the output directory of the project configuration.
If the DLL contains no exported routines or data, the
import library is not created.
Checking the DLL Symbol Export Table
To make sure that everything that you want to be
visible shows up in the export table, look at the export information of an