# PETSc's makefile system can't find MKL

I'm learning PETSc and trying to make the examples written in C. However, when I use the provided makefile, I get the following error:

/usr/bin/ld: cannot find -lmkl


When I check in the mkl/lib directory, I find that none of the .a or .so files are called libmkl.

Do I need to recompile PETSc to have the built-in makefiles link to MKL?

Which library file should I link to if not lmkl?

-

## 1 Answer

This seems like a linking problem with Intel's Math Kernel Library. You have many questions, so I will try to address each one.

In general, when there is a linking problem, especially "cannot find -lfoo", check the search directories. These are options that are usually specified with -L such as "-L /path/to/libraries". In your case, the intel compilers should usually accept the "-lmkl" option which internally specifies the location to the libraries. This does not solve your problem, though.

Since you are usually PETSc, and you are getting this error, it means that you are trying to switch the compilers or BLAS/LAPACK library after building PETSc. This is not supported. So, yes, you will need to reconfigure and rebuild specifying the Intel compilers and MKL. See the installation help for more information.

There are many libraries that need to be linked so that you can use Intel's MKL. Intel even made a helpful page to build the command-line link option.

-
As far as switching compilers or the LAPACK libarary, would updating either to a new version suffice to cause problems? –  Dan Dec 20 '11 at 23:37
Yes, because if the new compilers or LAPACK library aren't application binary compatible (ABI) then the linking will not work, which is what you're seeing. Plus, Intel is notorious about changing the linking commands between versions. –  Sean Farley Dec 21 '11 at 3:16