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.

You can use the -i-static option to force the linker to use the static versions of the Intel-supplied 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 octagon.o \

     -lifport -lifcoremt -limf -lm -lcxa \

     -lpthread -lirc -lunwind -lc -lirc_s

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.

If you are using the ifort command to link, you can use the -Qoption command to pass options to the linker. (You cannot use -Qoption on the ld command line.)

For more information on shared libraries, see Creating Libraries.

For more information on relevant compiler options, see the Compiler Options reference.

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: