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
.
If you successfully completed the
Scripts to Set Environment Variables Setting Environment Variables
step of the Getting Started process, you can omit
in the examples for dynamic linking.
-I$MKLINCLUDE
in all the examples and omit
-L$MKLPATH
- Static linking ofmyprog.fandOpenMP* threaded:Intel® oneAPI Math Kernel Libraryifort 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 ofmyprog.fandOpenMP* threaded:Intel® oneAPI Math Kernel Libraryifort myprog.f-L$MKLPATH -I$MKLINCLUDE-lmkl_intel-lmkl_intel_thread-lmkl_core-liomp5-lpthread -lm
- Static linking ofmyprog.fand sequential version of:Intel® oneAPI Math Kernel Libraryifort 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 ofmyprog.fand sequential version of:Intel® oneAPI Math Kernel Libraryifort myprog.f-L$MKLPATH -I$MKLINCLUDE-lmkl_intel-lmkl_sequential-lmkl_core-lpthread -lm
- Static linking ofmyprog.f, Fortran 95 LAPACK interface, andOpenMP* threaded:Intel® oneAPI Math Kernel Libraryifort 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 ofmyprog.f, Fortran 95 BLAS interface, andOpenMP* threaded:Intel® oneAPI Math Kernel Libraryifort 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 ofmyprog.candthreaded with Intel® Threading Building Blocks (Intel® TBB), provided that theIntel® oneAPI Math Kernel LibraryTBBROOTenvironment variableis defined.icc 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/lib/ia32/gcc.4.8 -ltbb -lstdc++ -lpthread -lm
- Dynamic linking ofmyprog.candthreaded with Intel® TBB, provided that theIntel® oneAPI Math Kernel LibraryLD_LIBRARY_PATHenvironment variable contains the path to Intel® TBB library:icc myprog.c -I$MKLINCLUDE -L$MKLPATH -lmkl_intel -lmkl_tbb_thread -lmkl_core -lstdc++ -lpthread -lm