PDA

View Full Version : How to link Lapack?



mmar
May 19th, 2011, 11:26 AM
Hi!

I have just installed Lapack and Blas from Synaptic. I'm trying to compile this simple program:


#include <stdio.h>
#include <clapack.h>
#include <cblas.h>


void sgesv( int* n, int* nrhs, float* a, int* lda, int* ipiv, float* b, int* ldb, int* info );


int main()
{

int uno = 1;
int tres = 3;

float A [ ]={
2, 1, 1,
3, -1, 1,
0, 2, 3};

float x[ ]= {0, 0, 0};

float b [ ] = {1, 0, 3};

int ipiv[3];
int info;
int i;

sgesv (&tres, &uno, A, &tres, ipiv, b, &tres, &info);

for (i=0; i<3; ++i) printf("%f\n", x[i]);

return 0;

}But I get the following error: "undefinded reference to 'sgesv'" when I type "gcc lap.c -o lap -llapack -lblas"
I wrote another program that just uses BLAS and compiles fine with "gcc prueba.c -o prueba -lblas". However, this program using the
lapack routine returns an error. Have I missed anything? What am I doing wrong?

Thanks in advance

Arndt
May 19th, 2011, 12:05 PM
Hi!

I have just installed Lapack and Blas from Synaptic. I'm trying to compile this simple program:

But I get the following error: "undefinded reference to 'sgesv'" when I type "gcc lap.c -o lap -llapack -lblas"
I wrote another program that just uses BLAS and compiles fine with "gcc prueba.c -o prueba -lblas". However, this program using the
lapack routine returns an error. Have I missed anything? What am I doing wrong?

Thanks in advance

It seems this page is relevant: http://www.netlib.org/clapack/faq.html. So the function is called sgesv_.

mmar
May 19th, 2011, 09:42 PM
Thank you for your help. I totally forgot the underscore because I'm using a guide for Fortran.