8

I installed liblapack-dev and its dependencies using Synaptic, and I included <lapack.h> in my code.

If I try to compile my program like this...

mpicc program.c -llapack -o output

...I get the following error:

program.c:4:20: fatal error: lapack.h: No such file or directory 
compilation terminated.

How can I fix this? I've already spent hours googling for a solution but nothing helped.

I'm using Linux Mint, but I tried the same thing on the latest version of Ubuntu and it still wouldn't work. Same thing when I try "eliminating" MPI from my program and compiling with gcc.

iCanLearn
  • 336
  • 1
  • 4
  • 17
  • 2
    `locate` the `lapack.h` header, perhaps you need to set the include path of the compiler. – Daniel Fischer Dec 25 '12 at 22:05
  • @Daniel Fischer: How exactly do I locate the lapack.h header? If I type "locate lapack.h" into the terminal I don't get anything. If I type "locate liblapack-dev" I get some results. And how do I set the include path of the compiler? I mean, I already tried doing something like that (or at least I thought I did), but with no success. – iCanLearn Dec 25 '12 at 22:12
  • Most compilers have a `-i` or similar command line option allowing for the specifying of include paths. Consult your help documentation, appropriate man page, or google for your specific compiler's command options. – StarPilot Dec 25 '12 at 22:17
  • If `locate lapack.h` doesn't find it, you may not have it at all, or the database `locate` uses hasn't been updated since installing lapack. In the latter case, running `updatedb` (probably requires `sudo`) would allow it to be `locate`d. You can also use `find` (or the GUI interface to that if Mint has one) to search it. Probably it would be under one of `/usr/include`, `/user/lib`, `/usr/lib64` or `/usr/local`. Re include path, what StarPilot said, but I don't know mpicc. – Daniel Fischer Dec 25 '12 at 22:22
  • @Daniel Fischer: I tried updating the database, and now I only get "/usr/include/atlas/clapack.h". – iCanLearn Dec 25 '12 at 22:31
  • Could be that `#include ` is what you need. Maybe worth a try. – Daniel Fischer Dec 25 '12 at 22:36
  • @Daniel Fischer: I've already tried that. :( – iCanLearn Dec 25 '12 at 22:38

2 Answers2

17

I experienced a similar issue on Debian. I noticed that

dpkg -L liblapack-dev

did not return a single header file. So I did some searching with apt-cache and found what appears to be C headers. After installing via

sudo apt-get install liblapacke-dev

(note the extra e!), I was able to compile a minimal working example, found here. Modifying the include at the top to read

#include <lapacke.h>

and compiling with

gcc -llapack lapack_example.c

successfully runs on my system. Hope this helps someone.

Stephen Shank
  • 362
  • 3
  • 8
3

Answering because it doesn't fit in a comment:

The manual says:

Standard C language APIs for LAPACK

collaboration LAPACK and INTEL Math Kernel Library Team

    LAPACK C INTERFACE is now included in the LAPACK package (in the lapacke directory)

    LAPACKE User Guide

    Updated: April 20, 2012

    header files: lapacke.h, lapacke_config.h, lapacke_mangling.h, lapacke_utils.h

so perhaps you need to

#include <lapacke.h>
Daniel Fischer
  • 181,706
  • 17
  • 308
  • 431
  • I'll upvote this because you're trying to help me, but the truth is: I actually tried that *first*, and it is what I ultimately want to use (lapacke), but then I realised that not even lapack (without the "e") works for me and figured I should get that working first (since lapacke is a part of lapack). – iCanLearn Dec 25 '12 at 23:06
  • Ah, but the point is that there is no `lapack.h`, as far as I can determine. Maybe the [user's guide](http://www.netlib.org/lapack/lug/) sheds more light. – Daniel Fischer Dec 25 '12 at 23:12
  • There is lapack.h because I've seen programs using it run on other computers. I've already seen the user's guide. Admittedly, I haven't read the whole thing, but still, I haven't found a solution to my problems in the parts of it which seemed relevant. – iCanLearn Dec 25 '12 at 23:17
  • 1
    I've searched the sources, at least the LAPACK package has no `lapack.h`. The C interface it provides is LAPACKE, but you have to prefix the functions you call, `info = LAPACKE_dgels(LAPACK_ROW_MAJOR,'N',m,n,nrhs,*a,lda,*b,ldb);` etc. Maybe there was a `lapack.h` in older versions, or it comes from another package where it is used. I can't find anything helpful about using LAPACK with `lapack.h` with google, sorry. – Daniel Fischer Dec 26 '12 at 00:03
  • Yeah, sorry, I think you might be right, "lapack.h" might even be a Fortran-only thing (and what I saw was possibly "mkl_lapack.h"?) – iCanLearn Dec 26 '12 at 00:14