**EDIT including update at the end of the question.
When I try to use dsymm from LAPACKE, I get a "linker command failed" error. (So, probably I am compiling the code wrong?) Here is the code in question:
#include "matrix_multiplication_attempt.h"
#include <stdio.h>
#include "lapacke.h"
int main ( )
{
/* 3x3 A matrix (symmetric) */
double a[] = {1,2,6,
2,3,1,
6,1,4};
/* 3x3 B Matrix */
double b[] = {2,3,4,
3,6,7,
4,7,4};
/* 3x3 C Matrix */
double c[] = {0,0,0,
0,0,0,
0,0,0};
char side, uplo;
int M,N, lda, ldb, ldc;
double alpha, beta,info;
side= 'L';
uplo='L';
M=3;
N=3;
alpha=1.0;
beta=0.0;
lda=3;
ldb=3;
info=8.0;
info=cblas_dsymm(side, uplo,
M,N, alpha, a,lda,
b,ldb,beta,c,ldc);
return info;
And here is the error I get:
matrix_multiplication_attempt.c:51:10: warning: implicit declaration of
function 'lapacke_dsymm' is invalid in C99
[-Wimplicit-function-declaration]
info=lapacke_dsymm(side, uplo,
^
1 warning generated.
Undefined symbols for architecture x86_64:
"_lapacke_dsymm", referenced from:
_main in matrix_multiplication_attempt-e2c0b9.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I'm not experienced with C, so there is probably a simple mistake. Any insight is greatly appreciated.
EDIT: Thank you, francis, the issue was that dsymm is not part of LAPACK, but in BLAS and your solution works. Now, my updated question is: how can I link LAPACKE so that I can use both LAPACKE and BLAS routines in the same file? One of my attempts at compiling is:
gcc matrix_multiplication_attempt.c -o matrix_multiplication_attempt -lblas -Wall -I/usr/local/opt/lapack/include -L/usr/local/opt/lapack/lib/ -llapacke
but this gives the error
Undefined symbols for architecture x86_64:
"_cblas_dsymm", referenced from:
_main in matrix_multiplication_attempt-76b8f6.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
LAPACKE_dsymm
I very much suspect this is a typo! – Antti Haapala -- Слава Україніdsymm
wasn't exported by lapacke. – Antti Haapala -- Слава Україні/usr/local/opt/lapack/lib/
contains a blas library which does not contains cblas. If there is a cblas library, try to link against it. It may not be the case. Indeed, if Lapack has been compiled by cmake, the CmakeLists.txt containsoption(CBLAS "Build CBLAS" OFF)
: the default mode is to build Lapack and Lapacke without compiling cblas. Hence, to build the makefile and recompile Lapack with cblas, you can use something likecmake -DCBLAS=ON
. – francis