Visible to Intel only — GUID: GUID-6CA209BC-3362-46C4-8B25-A42E0EB3717E
Visible to Intel only — GUID: GUID-6CA209BC-3362-46C4-8B25-A42E0EB3717E
Linking on IA-32 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 withicx.
In these examples,
MKLPATH=$MKLROOT/lib32,
MKLINCLUDE=$MKLROOT/include.
In these examples, MKLPATH=$MKLROOT/lib32, and MKLINCLUDE=$MKLROOT/include.
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):
ifort myprog.f -L$MKLPATH -I$MKLINCLUDE
-Wl,--start-group $MKLPATH/libmkl_intel.a $MKLPATH/libmkl_intel_thread.a $MKLPATH/libmkl_core.a
-Wl,--end-group -liomp5 -lpthread -lmDynamic linking of myprog.f and OpenMP* threadedIntel® oneAPI Math Kernel Library (oneMKL):
ifort myprog.f -L$MKLPATH -I$MKLINCLUDE
-lmkl_intel -lmkl_intel_thread -lmkl_core -liomp5 -lpthread -lmStatic linking of myprog.f and sequential version of Intel® oneAPI Math Kernel Library (oneMKL):
ifort myprog.f -L$MKLPATH -I$MKLINCLUDE
-Wl,--start-group $MKLPATH/libmkl_intel.a $MKLPATH/libmkl_sequential.a $MKLPATH/libmkl_core.a
-Wl,--end-group -lpthread -lmDynamic linking of myprog.f and sequential version of Intel® oneAPI Math Kernel Library (oneMKL):
ifort myprog.f -L$MKLPATH -I$MKLINCLUDE
-lmkl_intel -lmkl_sequential -lmkl_core -lpthread -lmStatic linking of myprog.f, Fortran BLAS and 95 LAPACK interfaces, and OpenMP* threadedIntel® oneAPI Math Kernel Library (oneMKL):
ifort myprog.f -L$MKLPATH -I$MKLINCLUDE -I$MKLINCLUDE/mkl/ia32
-lmkl_lapack95
-Wl,--start-group $MKLPATH/libmkl_intel.a $MKLPATH/libmkl_intel_thread.a $MKLPATH/libmkl_core.a
-Wl,--end-group
-liomp5 -lpthread -lmStatic linking of myprog.c and Intel® oneAPI Math Kernel Library (oneMKL) threaded with Intel® Threading Building Blocks (Intel® TBB), provided that the TBBROOT environment variable is defined.
icx myprog.c -I$MKLINCLUDE -Wl,--start-group $MKLPATH/libmkl_intel.a $MKLPATH/libmkl_tbb_thread.a $MKLPATH/libmkl_core.a -Wl,--end-group -L$TBBROOT/lib32 -ltbb -lstdc++ -lpthread -lm
Dynamic linking of myprog.c and Intel® oneAPI Math Kernel Library (oneMKL) threaded with Intel® TBB, provided that the LD_LIBRARY_PATH environment variable contains the path to Intel® TBB library:
icx myprog.c -I$MKLINCLUDE -L$MKLPATH -lmkl_intel -lmkl_tbb_thread -lmkl_core -lstdc++ -lpthread -lm