Closet...
...اینجا می‌نویسم برای اینکه یادم بمونه... تا راحت‌تر فراموش کنم
Tuesday, September 20, 2011
Compiling LAPACK in C++ code in Ubuntu 10.04

I rarely use LAPACK and when I need it to work I usually have bunch of coding and compiling problems! So once for all here is the notes I might need next time:

In the code:
Your are compiling a C++ code, ya? So extern the part that are linked from "C" codes. That is, you need to add something like

extern "C" void   dgemm_(char *transa, char *transb,int *m, int *n, int *k, double *alpha, double *a, int *lda, double *b, int *ldb, double *beta, double *c, int *ldc );

to declare dgemm_ and use it in the code as

dgemm_ (&charN, &charN, &n, &k, &n, &dpone, Acopy, &n, b, &n, &dmone,
bcopy, &n);

[1], [2]

When compiling:
Compile with something like

g++ -Wall -O3 svd_test.cpp  -L/usr/local/lib/ -llapack -lf77blas -lcblas -latlas -lg2c -lm


Note about the g2c library:

In Ubuntu 10.04 LTS, the libg2c library is not included per default. If 'ls /usr/lib/libg2c.*' does not list anything this is the case on your machine. You then want to install the packages gcc-3.4-base and libg2c0 e.g. from  

http://packages.ubuntu.com/hardy/gcc-3.4-base and
http://packages.ubuntu.com/hardy/libg2c0.

After installation, you have to create a symbolic link by
'cd /usr/lib' and 'ln -s libg2c.so.0 libg2c.so'
[3]

Now go back to work!

Labels: ,