I am trying to use the cblas library for matrix multiplication, but get "undefined reference to `cblas_dgemm'" when I try to compile, even though the library should be linked properly.
Code in test.c
looks like this:
...
#include <cblas.h>
void reference_dgemm (int N, double ALPHA, double* A, double* B, double* C)
{
int ORDER = 101; // row major
char TRANSA = 111; // no transpose
char TRANSB = 111;
int M = N;
int K = N;
double BETA = 1.;
int LDA = N;
int LDB = N;
int LDC = N;
cblas_dgemm(ORDER, TRANSA, TRANSB, M, N, K, ALPHA, A, LDA, B, LDB, BETA, C, LDC);
}
is compiled like this:
gcc -lblas test.c
giving this error:
/tmp/cc9fVU41.o: In function `reference_dgemm':
test.c:(.text+0xc7): undefined reference to `cblas_dgemm'
collect2: error: ld returned 1 exit status
I have tried using #include <gsl/gsl_cblas.h>
with -lgslcblas
instead, as in this example, same problem. Format and name of the referenced function I got from /usr/include/cblas.h