Intel® Fortran Compiler 16.0 User and Reference Guide
This topic only applies to Intel® Many Integrated Core Architecture (Intel® MIC Architecture).
Using xiar or the equivalent xild -lib to create a static archive library containing routines with offload code requires the following actions:
Specify the -qoffload-build option, which causes xiar to create both a library that for the CPU, lib.a, and a corresponding library for the coprocessor, libMIC.a.
When supplying the name of the library and the list of its member files to xiar or xild, include only the file names associated with the CPU library and CPU object files, such as lib.a and file.o. xiar and xild automatically manipulate the corresponding coprocessor library and member files, libMIC.a and fileMIC.o, respectively.
Use the same options available to ar, including d (Delete), r (Replace), m (Move) and x (Extract). For more information, see the man page for ar.
The syntax to use these options is as follows:
xiar –qoffload-build ar options archive [member...]
xild -lib –qoffload-build ar options archive [member...]
When linking a static archive that contains offload code, use the linker options -Lpath and -llibname. The compiler driver automatically incorporates the corresponding coprocessor library, libMIC.a, into the linking phase.
The following xiar command creates or modifies the CPU library libsample.a and coprocessor library libsampleMIC.a:
xiar -qoffload-build rcs libsample.a obj1.o obj2.o
libsample.a contains the CPU object files obj1.o and obj2.o. libsampleMIC.a contains the coprocessor object files obj1MIC.o and obj2MIC.o.
Either of the following commands compiles and links myprogram.f90 with the static library:
ifort myprogram.f90 libsample.a ifort myprogram.f90 -lsample