4
$\begingroup$

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?

$\endgroup$

1 Answer 1

3
$\begingroup$

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.

$\endgroup$
2
  • $\begingroup$ As far as switching compilers or the LAPACK libarary, would updating either to a new version suffice to cause problems? $\endgroup$
    – Dan
    Dec 20, 2011 at 23:37
  • 2
    $\begingroup$ 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. $\endgroup$ Dec 21, 2011 at 3:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.