Developer Guide

Developer Guide for Intel® oneAPI Math Kernel Library macOS*

ID 766688
Date 7/13/2023
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

Linking on Intel(R) 64 Architecture Systems

The following examples illustrate linking that uses Intel(R) compilers.

Most examples use the .f Fortran source file. C/C++ users should instead specify a .cpp (C++) or .c (C) file and replace ifort with icc.

In these examples,
MKLPATH=$MKLROOT/lib
,
MKLINCLUDE=$MKLROOT/include
.

NOTE:

If you successfully completed the Scripts to Set Environment Variables Setting Environment Variables step of the Getting Started process, you can omit -I$MKLINCLUDE in all the examples and omit -L$MKLPATH in the examples for dynamic linking.

  • Static linking of myprog.f and OpenMP* threadedIntel® oneAPI Math Kernel Library (oneMKL) supporting the LP64 interface:

    ifort myprog.f -L$MKLPATH -I$MKLINCLUDE
    $MKLPATH/libmkl_intel_lp64.a $MKLPATH/libmkl_intel_thread.a
    $MKLPATH/libmkl_core.a $MKLPATH/libmkl_intel_lp64.a $MKLPATH/libmkl_intel_thread.a $MKLPATH/libmkl_core.a -liomp5 -lpthread -lm

  • Dynamic linking of myprog.f and OpenMP* threadedIntel® oneAPI Math Kernel Library (oneMKL) supporting the LP64 interface:

    ifort myprog.f -L$MKLPATH -I$MKLINCLUDE -Wl,-rpath,$MKLPATH
    -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core
    -liomp5 -lpthread -lm

  • Static linking of myprog.f and sequential version of Intel® oneAPI Math Kernel Library (oneMKL) supporting the LP64 interface:

    ifort myprog.f -L$MKLPATH -I$MKLINCLUDE
    $MKLPATH/libmkl_intel_lp64.a $MKLPATH/libmkl_sequential.a
    $MKLPATH/libmkl_core.a $MKLPATH/libmkl_intel_lp64.a $MKLPATH/libmkl_sequential.a $MKLPATH/libmkl_core.a -lpthread -lm

  • Dynamic linking of myprog.f and sequential version of Intel® oneAPI Math Kernel Library (oneMKL) supporting the LP64 interface:

    ifort myprog.f -L$MKLPATH -I$MKLINCLUDE -Wl,-rpath,$MKLPATH
    -lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lpthread -lm

  • Static linking of myprog.f and OpenMP* threadedIntel® oneAPI Math Kernel Library (oneMKL) supporting the ILP64 interface:

    ifort myprog.f -L$MKLPATH -I$MKLINCLUDE
    $MKLPATH/libmkl_intel_ilp64.a $MKLPATH/libmkl_intel_thread.a
    $MKLPATH/libmkl_core.a $MKLPATH/libmkl_intel_ilp64.a $MKLPATH/libmkl_intel_thread.a $MKLPATH/libmkl_core.a -liomp5 -lpthread -lm

  • Dynamic linking of myprog.f and OpenMP* threadedIntel® oneAPI Math Kernel Library (oneMKL) supporting the ILP64 interface:

    ifort myprog.f -L$MKLPATH -I$MKLINCLUDE -Wl,-rpath,$MKLPATH
    -lmkl_intel_ilp64 -lmkl_intel_thread -lmkl_core -liomp5 -lpthread -lm

  • Dynamic linking of user code myprog.f and OpenMP* threadedor sequential Intel® oneAPI Math Kernel Library (oneMKL)(Call appropriate functions or set environment variables to choose threaded or sequential mode and to set the interface):

    ifort myprog.f -L$MKLPATH -Wl,-rpath,$MKLPATH -lmkl_rt
  • Static linking of myprog.f, Fortran BLAS and 95 LAPACK interfaces, and OpenMP* threadedIntel® oneAPI Math Kernel Library (oneMKL) supporting the LP64 interface:

    ifort myprog.f -L$MKLPATH -I$MKLINCLUDE -I$MKLINCLUDE/intel64/lp64
    -lmkl_lapack95_lp64 $MKLPATH/libmkl_intel_lp64.a $MKLPATH/libmkl_intel_thread.a
    $MKLPATH/libmkl_core.a $MKLPATH/libmkl_intel_thread.a $MKLPATH/libmkl_core.a $MKLPATH/libmkl_intel_thread.a $MKLPATH/libmkl_core.a -liomp5 -lpthread -lm

  • Static linking of myprog.c and Intel® oneAPI Math Kernel Library (oneMKL) threaded with Intel® Threading Building Blocks (Intel® TBB), provided that the LIBRARY_PATH environment variable contains the path to Intel TBB library:

    icc myprog.c -L$MKLPATH -I$MKLINCLUDE -Wl,--start-group $MKLPATH/libmkl_intel_lp64.a $MKLPATH/libmkl_tbb_thread.a $MKLPATH/libmkl_core.a -Wl,--end-group -ltbb -lstdc++ -lpthread -lm

  • Dynamic linking of myprog.c and Intel® oneAPI Math Kernel Library (oneMKL) threaded with Intel® TBB, provided that the LIBRARY_PATH environment variable contains the path to Intel® TBB library:

    icc myprog.c -L$MKLPATH -I$MKLINCLUDE -Wl,-rpath,$MKLPATH
    -lmkl_intel_lp64 -lmkl_tbb_thread -lmkl_core -ltbb -lstdc++ -lpthread -lm

See Also