Creating Shared Libraries

To create a shared library from a Fortran source file, process the files using the ifort command:

Creating a Shared Library with a Single ifort Command

You can create a shared library (.so) file with a single ifort command:

ifort -shared  octagon.f90

 The -shared option is required to create a shared library. The name of the source file is octagon.f90. You can specify multiple source files and object files.

The -o option was omitted, so the name of the shared library file is octagon.so.

Since you omitted the -c option, you do not need to specify the standard list of Fortran libraries.

Creating a Shared Library with ifort and ld Commands

You first must create the .o file, such as octagon.o in the following example:

ifort -c octagon.f90

The file octagon.o is then used as input to the ld command to create the shared library named octagon.so:

ld -shared -no_archive octagon.o \

     -lifport -lifcoremt -limf -lm -lirc -lcxa \

     -lunwind -lpthread -lc

Note the following:

It is probably a good idea to look at the output of the -dryrun command to find the names of all the libraries used so you can specify them correctly.

You can use the -Qoption command to pass options to ld.

See also the ld(1) reference page.

Shared Library Restrictions

When creating a shared library with ld, be aware of the following restrictions:

Installing Shared Libraries

Once the shared library is created, it must be installed for private or system-wide use before you run a program that refers to it: