Page 1 of 1

Use Lapack 3.1.0 with VC++ 2005

PostPosted: Fri Jul 13, 2007 5:41 am
by dvdjimmy
Dear all,

I know that similar questions are coming nearly everyday but unfortunately no thread deals exactly with the solution to a (in my opinion) common problem:

As the Subject tell you, I want to build the lapack and blas libs to use with vc++ 2005.

Currently I downloaded the clapack-windows 3 package and already compiled it with the included project files for vc++2005.

I was also able to compile and execute all the sample files.

Now when I try to build an own sample like the following:

Code: Select all
#include <stdio.h>
#include "M:\C-Development\lapack_tests\CLAPACK-windows\BLAS\WRAP\blaswrap.h"
#include "M:\C-Development\lapack_tests\CLAPACK-windows\BLAS\WRAP\f2c.h"
#include "M:\C-Development\lapack_tests\CLAPACK-windows\BLAS\WRAP\cblas.h"


int main(int argc, char* argv[])
{
   double m[] = {
  3, 1, 3,
  1, 5, 9,
  2, 6, 5
};

double x[] = {
  -1, -1, 1
};

double y[] = {
  0, 0, 0
};


  int i, j;

  for (i=0; i<3; ++i) {
    for (j=0; j<3; ++j) printf("%5.1f", m[i*3+j]);
    putchar('\n');
  }

  cblas_dgemv(CblasRowMajor, CblasNoTrans, 3, 3, 1.0, m, 3,
         x, 1, 0.0, y, 1);

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

  return 0;
}

I get the following linker error:

error LNK2019: unresolved external symbol "void __cdecl cblas_dgemv(enum CBLAS_ORDER,enum CBLAS_TRANSPOSE,int,int,double,double const *,int,double const *,int,double,double *,int)" (?cblas_dgemv@@YAXW4CBLAS_ORDER@@W4CBLAS_TRANSPOSE@@HHNPBNH2HNPANH@Z) referenced in function _main

As it is a debug project at the moment, I told the linker to use the debug libraries in the following order:

\Debug\tmglib.lib
\Debug\clapack.lib
\Debug\blas.lib
\Debug\libF77.lib
\Debug\libI77.lib
kernel32.lib

I have also tried to set my project as a C-Only projekt and not a c++ project, but this did not solve the problem.

Could you help me out or point me in the right direction on how I can use the lapack/blas or clapack/blas library with vc++ 2005.

If there is an easy way to compile the fortran lapack version and then use it with vc++ I can also try this as I have access to the intel fortran 9.1 compiler for windows.

Thank you a lot in advance.

With best regards.

dvdjimmy

PostPosted: Fri Jul 13, 2007 7:12 am
by Julie
dvdjimmy,

if you decide to use the CBLAS library, you need to link your program with it.
you can download it from http://www.netlib.org/clapack//cblas.tgz.
Julie

PostPosted: Fri Jul 13, 2007 7:21 am
by dvdjimmy
@Julie

yes I know. But as you can see in the entrance posting - I already linked agains all the libraries I have.

Or is one missing??

PostPosted: Fri Jul 13, 2007 10:05 am
by Julie
Yes one is missing: the CBLAS library.
\Debug\tmglib.lib
\Debug\clapack.lib
\Debug\cblas.lib
\Debug\blas.lib
\Debug\libF77.lib
\Debug\libI77.lib
kernel32.lib

Add cblas.lib before blas.lib by once cblas.lib is installed on your machine.

You may need the g2c library to link.
Julie

PostPosted: Mon Jul 16, 2007 2:35 am
by dvdjimmy
@Julie:

thank you for pointing me into the right direction. Unfortunately I am now a little bit confused.

I downloaded the cblas.tgz source from netlib and then I had a look into the source files and found that they are not really different then the ones I already downloaded within the CLAPACK3-Windows.zip.

I thought that the BLAS delivered with CLAPACK3-Windows.zip is all I need because there are already only .c files in the BLAS folder :(

Or maybe I just did not fully understand the total BLAS/LAPACK relationships :)

Concerning the cblas.tgz I just downloaded. There is no makefile (unfortunately). Do you know if it should be enough to just replace the exisiting BLAS directory in CLAPACK3-Windows.zip with the new cblas files and then generate the library with the shipped blas makefile?

Thank you very much in advance.

Take care.

Joachim

PostPosted: Mon Jul 16, 2007 2:50 am
by dvdjimmy
ah...


I just looked a little bit closer at the blas directory inside the CLAPACK3-Windows.zip and it seems to me that this is already the cblas library :(

Now its even more confusing that the linker cannot find the function :(

Best regards,

Joachim

PostPosted: Sat Jul 21, 2007 4:17 am
by avhuynh
Hi dvdjimmy and Julie,

I also downloaded the lapack 3.1 for windows and followed the instruction to make nmake command but I could not produce anything. Could you tell me how did you compile it and where are the sample C++ that uses Lapack functions?

Alternatively, I inlcude the lapack_WIN32.lib into my VSC2005 project but when I call sgelss_(&(A.m),&(A.n),&nrhs,A.entry,&lda,
b.entry,&ldb,
s.entry[0],&rcond,&rank,
work.entry[0],&lwork,&info);
the linker can not find symbol _sgelss_

Could you please tell me how to out of this?

Thanks.
Vu

PostPosted: Mon Jul 23, 2007 9:23 am
by Julie
Vu,
You need the Intel FORTRAN compiler for Windows or the the PGI FORTRAN compiler for Windows to be able to use the nmake build.

Julie