title: How to call CLAPACK from C?
body: <p>I am trying to call a CLAPACK function from C. I downloaded CLAPACK-3.2.1 (from <a href="http://www.netlib.org/clapack/clapack.tgz" rel="nofollow">http://www.netlib.org/clapack/clapack.tgz</a>) and followed instructions here (<a href="http://people.sc.fsu.edu/~%20jburkardt/c_src/clapack/clapack.html" rel="nofollow">http://people.sc.fsu.edu/~%20jburkardt/c_src/clapack/clapack.html</a>). My CLAPACK distribution is this:</p>
  
  <pre><code>$ ls
  BLAS/  COPYING  F2CLIBS/  INCLUDE/  INSTALL/  Makefile  make.inc.example  my_example.c  README.install  SRC/  TESTING/
  </code></pre>
  
  <p>My file is <code>my_example.c</code> is simply:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include "blaswrap.h"
  #include "f2c.h"
  #include "clapack.h"
  
  int main()
  {
    char ta = 'N';
    char tb = 'N';
    double a[3][3];
    a[0][0] = 1;
    a[0][1] = 2;
    a[0][2] = 3;
    a[1][0] = 4;
    a[1][1] = 5;
    a[1][2] = 6;
    a[2][0] = 7;
    a[2][1] = 8;
    a[2][2] = 9;
    double b[3][3];
    b[0][0] = 1;
    b[0][1] = 0;
    b[0][2] = 0;
    b[1][0] = 0;
    b[1][1] = 0;
    b[1][2] = 0;
    b[2][0] = 5;
    b[2][1] = 5;
    b[2][2] = 5;
    double c[3][3];
    long int m = 3;
    long int n = 3;
    long int k = 3;
    double alpha = 1.0;
    double beta = 0.0;
    long int lda = 3;
    long int ldb = 3;
    long int ldc = 3;
  
    f2c_dgemm(&amp;ta, &amp;tb, &amp;m, &amp;n, &amp;k, &amp;alpha, &amp;a[0][0], &amp;lda, &amp;b[0][0], &amp;ldb, &amp;beta, &amp;c[0][0], &amp;ldc);
    printf("Resulting C[0][0]: %f\n", c[0][0]);
    return 0;
  }
  </code></pre>
  
  <p>When I compile it I get this:</p>
  
  <pre><code>$ gcc -I./INCLUDE -I./F2CLIBS/libf2c/ -I./BLAS/WRAP/ my_example.c BLAS/SRC/dgemm.c BLAS/SRC/xerbla.c BLAS/SRC/lsame.c -o my_example.o
  How can I get this to compile and run correctly?
  BLAS/SRC/xerbla.c: In function ‘xerbla_’:
  BLAS/SRC/xerbla.c:69:2: warning: incompatible implicit declaration of built-in function ‘printf’ [enabled by default]
  BLAS/SRC/xerbla.c:70:3: warning: format ‘%i’ expects argument of type ‘int’, but argument 3 has type ‘integer’ [-Wformat]
  </code></pre>
  
  <p>Is this the correct way to call a clapack function? Is the array passing correct?</p>
  
  <p>(PS I am not trying to dynamically link to existing clapack installation).</p>