Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29377 Discussions

simple instructions for linking to mkl_lapack on Mac OS 10.6?

bpabbott
Beginner
982 Views
I'm a new user of ifort and MKL.

I have a fairly large fortran project which includes both f77 and f90+ sources, and is build using a makefile. I'd like to replace Apple's vecLib with MKL.

My build terminates with ..

ifort -o ha_sdafemsda_v1 ha_sdafemsda_v1.o phiq_sdafemsda_v1.o sdafemsda_v1.o sub1_sdafemsda_v1.o cmatr.o cmatr_iso.o fmin_baw.o sub2.o vlim.o epsc_multilay_isomatr.o epsc_multilay_obl.o bpa_getargfromfile.o octave_matfile.o ha_sdafemsda_v1_cmd.o -shared-intel -L"/opt/intel/Compiler/11.1/067/Frameworks/mkl" -lmkl_lapack -lguide -lpthread
ipo: warning #11011: unable to find -lmkl_lapack
ipo: warning #11020: unresolved _zgeev_

It wouldn't surprize me to find I'm doing several things wrong. If one does not exist, can someone give me a brief set of instructions for how to build a simple fortran program that calls lapack?
0 Kudos
7 Replies
TimP
Honored Contributor III
982 Views
An important part of that would be to consult the link advisor in the right hand column of the forum header page. You appear to have copied some link options from a linux combinations of ifort and MKL of several years ago.
0 Kudos
bpabbott
Beginner
982 Views
Quoting - tim18
An important part of that would be to consult the link advisor in the right hand column of the forum header page. You appear to have copied some link options from a linux combinations of ifort and MKL of several years ago.

I went to the link-line advisor at


and obtained the link options below.

-L$(MKLPATH) $(MKLPATH)/libmkl_solver_sequential.a -lmkl_intel -lmkl_sequential -lmkl_core -lpthread

My MKLROOT and MLKPATH are set as

MKLROOT = /Developer/opt/intel/Compiler/11.1/067/Frameworks/mkl

MKLPATH = $(MKLROOT)/lib/32

Now I see

ifort -o ha_sdafemsda_v1 ha_sdafemsda_v1.o phiq_sdafemsda_v1.o sdafemsda_v1.o sub1_sdafemsda_v1.o cmatr.o cmatr_iso.o fmin_baw.o sub2.o vlim.o epsc_multilay_isomatr.o epsc_multilay_obl.o bpa_getargfromfile.o octave_matfile.o ha_sdafemsda_v1_cmd.o -L/opt/intel/Compiler/11.1/067/Frameworks/mkl/lib/32 /opt/intel/Compiler/11.1/067/Frameworks/mkl/lib/32/libmkl_solver_sequential.a -lmkl_intel -lmkl_sequential -lmkl_core -lpthread
ipo: warning #11009: file format not recognized for /opt/intel/Compiler/11.1/067/Frameworks/mkl/lib/32/libmkl_intel.dylib
ipo: warning #11009: file format not recognized for /opt/intel/Compiler/11.1/067/Frameworks/mkl/lib/32/libmkl_sequential.dylib
ipo: warning #11009: file format not recognized for /opt/intel/Compiler/11.1/067/Frameworks/mkl/lib/32/libmkl_core.dylib
ipo: warning #11020: unresolved _zgeev_

0 Kudos
TimP
Honored Contributor III
982 Views
Have you mixed 64-bit build and 32-bit libraries? The environment paths and -L should be set automatically when you have your compiler environment set, since you are using the MKL which comes with the compiler.
0 Kudos
bpabbott
Beginner
982 Views
Quoting - tim18
Have you mixed 64-bit build and 32-bit libraries? The environment paths and -L should be set automatically when you have your compiler environment set, since you are using the MKL which comes with the compiler.

Your hypothesis makes sense to me. How might I modify what I'm doing to confirm?
0 Kudos
TimP
Honored Contributor III
982 Views
You would simply set up the environment variables by sourceing the ifortvars compiler script. Then, you would leave out the -L specification, as the correct MKL library folder should be on the search path already.
By the way, a -L specification ends with a directory name, doesn't include any specific library. It would not work to search a library for itself or other libraries, which is what you specified.
0 Kudos
bpabbott
Beginner
982 Views
Quoting - tim18
You would simply set up the environment variables by sourceing the ifortvars compiler script. Then, you would leave out the -L specification, as the correct MKL library folder should be on the search path already.
By the way, a -L specification ends with a directory name, doesn't include any specific library. It would not work to search a library for itself or other libraries, which is what you specified.

Are you sure my "-L" option is wrong?

-L/Developer/opt/intel/Compiler/11.1/067/Frameworks/mkl/lib/32

I tried running ifortvars ...

/opt/intel/Compiler/11.1/067/bin/ifortvars.sh ia32

... but my build still fails.

ifort -o ha_sdafemsda_v1 ha_sdafemsda_v1.o phiq_sdafemsda_v1.o sdafemsda_v1.o sub1_sdafemsda_v1.o cmatr.o cmatr_iso.o fmin_baw.o sub2.o vlim.o epsc_multilay_isomatr.o epsc_multilay_obl.o bpa_getargfromfile.o octave_matfile.o ha_sdafemsda_v1_cmd.o -L/Developer/opt/intel/Compiler/11.1/067/Frameworks/mkl/lib/32 /Developer/opt/intel/Compiler/11.1/067/Frameworks/mkl/lib/32/libmkl_solver_sequential.a -lmkl_intel -lmkl_sequential -lmkl_core -lpthread
ipo: warning #11009: file format not recognized for /Developer/opt/intel/Compiler/11.1/067/Frameworks/mkl/lib/32/libmkl_intel.dylib
ipo: warning #11009: file format not recognized for /Developer/opt/intel/Compiler/11.1/067/Frameworks/mkl/lib/32/libmkl_sequential.dylib
ipo: warning #11009: file format not recognized for /Developer/opt/intel/Compiler/11.1/067/Frameworks/mkl/lib/32/libmkl_core.dylib
ipo: warning #11020: unresolved _zgeev_

When I remove the "-L" option the MKL libraries are not found.

ifort -o ha_sdafemsda_v1 ha_sdafemsda_v1.o phiq_sdafemsda_v1.o sdafemsda_v1.o sub1_sdafemsda_v1.o cmatr.o cmatr_iso.o fmin_baw.o sub2.o vlim.o epsc_multilay_isomatr.o epsc_multilay_obl.o bpa_getargfromfile.o octave_matfile.o ha_sdafemsda_v1_cmd.o /Developer/opt/intel/Compiler/11.1/067/Frameworks/mkl/lib/32/libmkl_solver_sequential.a -lmkl_intel -lmkl_sequential -lmkl_core -lpthread
ipo: warning #11011: unable to find -lmkl_intel
ipo: warning #11011: unable to find -lmkl_sequential
ipo: warning #11011: unable to find -lmkl_core
ipo: warning #11020: unresolved _zgeev_

Is there some way I can confirm the ifortvars script is functioning for correctly?




0 Kudos
bpabbott
Beginner
982 Views
It just occurred to me that I needed to source ifortvars.sh

source /opt/intel/Compiler/11.1/067/bin/ifortvars.sh ia32

After doing that, my program compiled and ran witiout problem ... both with and without the "-L" option.

Out of curiousity I did some speed comparisons. Using ifort and mkl_lapack, my program ran in 1.85 secs as compared to ifort with veclib which ran in 2.31 secs. Using gfortran with veclib resulted in an execution time of 2.86 secs.


0 Kudos
Reply