0

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's no 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/.

I'd appreciate some help in solving this issue.

What I've tried so far: I reinstalled (using homebrew) cblas and lapack, 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 Catalina 10.15.6, 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, just the title is similar).

nara
  • 146
  • 1
  • 7
  • When you say "I also tried adding to the search path" about the link to the github issue, what do you mean exactly? Because it says you should `export` it. It's an environment variable for `pkg-config`. You can use `pkg-config` in the `gcc` command line. Not sure if this is the same on a mac, but on linux like: `gcc myfile.c $(pkg-config --cflags --libs openblas)` – Emanuel P Apr 25 '21 at 01:15
  • @EmanuelP What I did was exactly running this command: export PKG_CONFIG_PATH=/usr/local/opt/openblas/lib/pkgconfig (Is that what you mean?) And it doesn't fix the issue. I still get the same error – nara Apr 25 '21 at 01:34

0 Answers0