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 with icc.

In these examples,
MKLPATH=$MKLROOT/lib/ia32_lin
,
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* threaded Intel MKL:

    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 -lm

  • Dynamic linking of myprog.f and OpenMP* threaded Intel MKL:

    ifort myprog.f -L$MKLPATH -I$MKLINCLUDE
    -lmkl_intel -lmkl_intel_thread -lmkl_core -liomp5 -lpthread -lm

  • Static linking of myprog.f and sequential version of Intel MKL:

    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 -lm

  • Dynamic linking of myprog.f and sequential version of Intel MKL:

    ifort myprog.f -L$MKLPATH -I$MKLINCLUDE
    -lmkl_intel -lmkl_sequential -lmkl_core -lpthread -lm

  • Dynamic linking of myprog.f and OpenMP* threaded or sequential Intel MKL (Call the mkl_set_threading_layer function or set value of the MKL_THREADING_LAYER environment variable to choose threaded or sequential mode):

    ifort myprog.f -lmkl_rt

  • Static linking of myprog.f, Fortran 95 LAPACK interface, and OpenMP* threaded Intel MKL:

    ifort myprog.f -L$MKLPATH -I$MKLINCLUDE -I$MKLINCLUDE/ia32
    -lmkl_lapack95
    -Wl,--start-group $MKLPATH/libmkl_intel.a $MKLPATH/libmkl_intel_thread.a $MKLPATH/libmkl_core.a
    -Wl,--end-group
    -liomp5 -lpthread -lm

  • Static linking of myprog.f, Fortran 95 BLAS interface, and OpenMP* threaded Intel MKL:

    ifort myprog.f -L$MKLPATH -I$MKLINCLUDE -I$MKLINCLUDE/ia32
    -lmkl_blas95
    -Wl,--start-group $MKLPATH/libmkl_intel.a $MKLPATH/libmkl_intel_thread.a $MKLPATH/libmkl_core.a
    -Wl,--end-group -liomp5 -lpthread -lm

  • Static linking of myprog.c and Intel MKL 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 -I$MKLINCLUDE -Wl,--start-group $MKLPATH/libmkl_intel.a $MKLPATH/libmkl_tbb_thread.a $MKLPATH/libmkl_core.a -Wl,--end-group -ltbb -lstdc++ -lpthread -lm

  • Dynamic linking of myprog.c and Intel MKL 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 -lmkl_intel -lmkl_tbb_thread -lmkl_core -ltbb -lstdc++ -lpthread -lm

Select sticky button color: 
Orange (only for download buttons)
For more complete information about compiler optimizations, see our Optimization Notice.