3

i need some linear algebra in my project and want use OpenBLAS for this. I downloaded the precompiled version (64bit version) and unpacked it to my projectfolder. In Visual Studio, i added include-, bin-, and lib-folder to my Project and ran the this example without problems.

Next, i wanted to look at LAPACK, so i added lapacke.h to the includes, which is in the same directory as cblas.h and is included in the official download. But now i get hundreds of errors, for every function, as if a lib file was missing or something. E.g. for this line

85 lapack_complex_float lapack_make_complex_float( float re, float im );

i get

PATH\include\lapacke.h(85): error C2146: syntax error: missing ';' before identifier 'lapack_make_complex_float'

I can't find any further information on how to set up OpenBLAS/LAPACK, they usually just say 'include the files', which i have. Otherwise the cblas example wouldn't run either. And the (relevant) examples i can find only use cblas.h, not lapacke.h

Can some tell me what i'm doing wrong?

1
  • For some reason my 'Hello' at the beginning is missing and can't be added using edit. so HELLO and does someone know why it's missing? Commented Nov 27, 2017 at 21:44

3 Answers 3

1

The problem is that OpenBlas uses C99 _Complex by default. This is not supported by Visual C++. You can solve this by using standard library definitions before including lapacke.h:

#include <complex>
#define lapack_complex_float std::complex<float>
#define lapack_complex_double std::complex<double>
#include <lapacke.h>
Sign up to request clarification or add additional context in comments.

Comments

0

Using std::complex is problematic unless OpenBLAS was built with LAPACK_COMPLEX_CPP otherwise the library uses a different complex type internally, usually C99 _Complex.

Modern versions of the Microsoft compiler (e.g. the one in VSTUDIO 2022) support a similar "_Complex" mechanism. Therefore I include the following header file prior to "lapacke.h"

#ifdef _MSC_VER

#include <complex.h>

#define LAPACK_COMPLEX_CUSTOM

typedef _Dcomplex lapack_complex_float;
typedef _Fcomplex lapack_complex_double;

#define lapack_complex_float_real(z)       (real(z))
#define lapack_complex_float_imag(z)       (imag(z))

#endif // _MSC_VER

See the lapack.h header file that ships with OpenBLAS how #define LAPACK_COMPLEX_CUSTOM overrides complex variable type definitions

1 Comment

Just wanted to add that you swapped the _Dcomplex->float and _Fcomplex->double above, if you could edit it for the next person that would help!
0

for current version of openblas/lapack (v0.3.30):

#define LAPACK_COMPLEX_CPP
#include <complex>
#include <lapacke.h> 

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.