我正在尝试使用cblas库进行矩阵乘法,但是当我尝试编译时,得到“未定义的对`cblas_dgemm'的引用”,即使该库应该正确链接。
test.c
中的代码如下所示:
...
#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);
}
编译如下:
gcc -lblas test.c
发出此错误:
/tmp/cc9fVU41.o: In function `reference_dgemm':
test.c:(.text+0xc7): undefined reference to `cblas_dgemm'
collect2: error: ld returned 1 exit status
我尝试将#include <gsl/gsl_cblas.h>
与-lgslcblas
一起使用,而不是this example,同样的问题。我从/usr/include/cblas.h