Trouble linking llapacke

270 Views Asked by At

I'm learning to use BLAS and LAPACK on C, and I'm having trouble with the very first step: importing and linking the libraries.

My device is a Mac, and apparently neither Xcode nor the compiler can find cblas.h, lapack.h, or lapacke.h, while all three are definitely is there in /usr/local/opt/openblas/include. I ended up writing the full path in the header like:

#include </usr/local/opt/openblas/include/cblas.h>
#include </usr/local/opt/openblas/include/lapacke.h>

With this (ugly) solution, Xcode and the compiler can now find the functions, but there's issue in linking -llapacke while making the executable.

There isn't any problem in linking -lapack and -lblas, but when I try -llapacke, I get the following error

ld: library not found for -llapacke

I checked, all three .h files are in /usr/local/opt/openblas/include/.

How can I solve this issue?

What I've tried so far:

I reinstalled (using Homebrew) libraries cblas and lapack, but it didn't fix it.

I also tried linking the library with the full path by doing this (following an answer to this question):

gcc -o main main.o utils.o -lm -I/usr/local/opt/openblas/include -L/usr/local/opt/openblas/lib -llapacke -llapack -lblas

I also tried adding to the search path following an answer on this page, and it didn't work:

PKG_CONFIG_PATH=/usr/local/opt/openblas/lib/pkgconfig

++ My OS is macOS v10.15.6 (Catalina), and my Xcode is 12.4.

++++ I also checked out this question with a very similar title, and it's not helpful (the question is quite different, and just the title is similar).

0

There are 0 best solutions below