The section provides specific linking examples that use Intel(R) compilers on systems based on the IA-32, Intel(R) 64, and IA-64 architectures. In these examples, <MKL path> and <MKL include> placeholders are replaced with user-defined environment variables $MKLPATH and $MKLINCLUDE, respectively. See also examples on linking with ScaLAPACK and Cluster FFT in Chapter 9.
The following examples use the .f Fortran source file. C/C++ users should instead specify a .cpp (C++) or .c (C) file and change the ifort linker to icc.
For assistance in finding the right link line, use the Web-based linking advisor available from http://software.intel.com/en-us/articles/intel-mkl-link-line-advisor.
1. Static linking of myprog.f and parallel 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
2. Dynamic linking of myprog.f and parallel Intel MKL:
ifort myprog.f -L$MKLPATH -I$MKLINCLUDE
-lmkl_intel -lmkl_intel_thread -lmkl_core -liomp5 -lpthread
3. 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
4. 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
5. Static linking of myprog.f, Fortran 95 LAPACK interface1, and parallel Intel MKL:
ifort myprog.f -L$MKLPATH -I$MKLINCLUDE -I$MKLINCLUDE/32 -lmkl_lapack95
-Wl,--start-group $MKLPATH/libmkl_intel.a $MKLPATH/libmkl_intel_thread.a $MKLPATH/libmkl_core.a -Wl,--end-group -liomp5 -lpthread
6. Static linking of myprog.f, Fortran 95 BLAS interface1, and parallel Intel MKL:
ifort myprog.f -L$MKLPATH -I$MKLINCLUDE -I$MKLINCLUDE/32 -lmkl_blas95
-Wl,--start-group $MKLPATH/libmkl_intel.a $MKLPATH/libmkl_intel_thread.a $MKLPATH/libmkl_core.a -Wl,--end-group -liomp5 -lpthread
7. Static linking of myprog.f, parallel version of an iterative sparse solver, and parallel Intel MKL:
ifort myprog.f -L$MKLPATH -I$MKLINCLUDE -lmkl_solver
-Wl,--start-group $MKLPATH/libmkl_intel.a $MKLPATH/libmkl_intel_thread.a $MKLPATH/libmkl_core.a -Wl,--end-group -liomp5 -lpthread
8. Static linking of myprog.f, sequential version of an iterative sparse solver, and sequential Intel MKL:
ifort myprog.f -L$MKLPATH -I$MKLINCLUDE -lmkl_solver_sequential
-Wl,--start-group $MKLPATH/libmkl_intel.a $MKLPATH/libmkl_sequential.a $MKLPATH/libmkl_core.a -Wl,--end-group -lpthread
1. Static linking of myprog.f and parallel Intel MKL supporting LP64 interface:
ifort myprog.f -L$MKLPATH -I$MKLINCLUDE
-Wl,--start-group $MKLPATH/libmkl_intel_lp64.a $MKLPATH/libmkl_intel_thread.a $MKLPATH/libmkl_core.a -Wl,--end-group -liomp5 -lpthread
2. Dynamic linking of myprog.f and parallel Intel MKL supporting LP64 interface:
ifort myprog.f -L$MKLPATH -I$MKLINCLUDE
-lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -liomp5 -lpthread
3. Static linking of myprog.f and sequential version of Intel MKL supporting LP64 interface:
ifort myprog.f -L$MKLPATH -I$MKLINCLUDE
-Wl,--start-group $MKLPATH/libmkl_intel_lp64.a $MKLPATH/libmkl_sequential.a $MKLPATH/libmkl_core.a -Wl,--end-group -lpthread
4. Dynamic linking of myprog.f and sequential version of Intel MKL supporting LP64 interface:
ifort myprog.f -L$MKLPATH -I$MKLINCLUDE
-lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lpthread
5. Static linking of myprog.f and parallel Intel MKL supporting ILP64 interface:
ifort myprog.f -L$MKLPATH -I$MKLINCLUDE
-Wl,--start-group $MKLPATH/libmkl_intel_ilp64.a $MKLPATH/libmkl_intel_thread.a $MKLPATH/libmkl_core.a -Wl,--end-group -liomp5 -lpthread
6. Dynamic linking of myprog.f and parallel Intel MKL supporting ILP64 interface:
ifort myprog.f -L$MKLPATH -I$MKLINCLUDE
-lmkl_intel_ilp64 -lmkl_intel_thread -lmkl_core -liomp5 -lpthread
7. Static linking of myprog.f, Fortran 95 LAPACK interface2, and parallel Intel MKL supporting LP64 interface:
ifort myprog.f -L$MKLPATH -I$MKLINCLUDE -I$MKLINCLUDE/em64t/lp64 -lmkl_lapack95_lp64
-Wl,--start-group $MKLPATH/libmkl_intel_lp64.a $MKLPATH/libmkl_intel_thread.a $MKLPATH/libmkl_core.a -Wl,--end-group -liomp5 -lpthread
8. Static linking of myprog.f, Fortran 95 BLAS interface1, and parallel Intel MKL supporting LP64 interface:
ifort myprog.f -L$MKLPATH -I$MKLINCLUDE -I$MKLINCLUDE/em64t/lp64 -lmkl_blas95_lp64
-Wl,--start-group $MKLPATH/libmkl_intel_lp64.a $MKLPATH/libmkl_intel_thread.a $MKLPATH/libmkl_core.a -Wl,--end-group -liomp5 -lpthread
9. Static linking of myprog.f, parallel version of an iterative sparse solver, and parallel Intel MKL supporting LP64 interface:
ifort myprog.f -L$MKLPATH -I$MKLINCLUDE -lmkl_solver_lp64
-Wl,--start-group $MKLPATH/libmkl_intel_lp64.a $MKLPATH/libmkl_intel_thread.a $MKLPATH/libmkl_core.a -Wl,--end-group -liomp5 -lpthread
10. Static linking of myprog.f, sequential version of an iterative sparse solver, and sequential Intel MKL supporting LP64 interface:
ifort myprog.f -L$MKLPATH -I$MKLINCLUDE -lmkl_solver_lp64_sequential
-Wl,--start-group $MKLPATH/libmkl_intel_lp64
$MKLPATH/libmkl_sequential.a $MKLPATH/libmkl_core.a -Wl,--end-group -lpthread
1. See Fortran 95 Interfaces to LAPACK and BLAS for information on how to build Fortran 95 LAPACK and BLAS interface libraries.
2. See Fortran 95 Interfaces to LAPACK and BLAS for information on how to build Fortran 95 LAPACK and BLAS interface libraries.