The LAPACK forum has moved to https://github.com/Reference-LAPACK/lapack/discussions.

Another problem of linking on zgetrf

Open discussion regarding features, bugs, issues, vendors, etc.

Another problem of linking on zgetrf

Postby Mercury » Tue Aug 07, 2007 4:11 am

Hello again!

I got another problem of linking when I try to use the getrf function:

zgetrf.c:7: warning: type defaults to 'int' in declaration of 'zgetrf_'
zgetrf.c: In function 'main':
zgetrf.c:25: warning: 'info' is used uninitialized in this function
lapack_LINUX.a(zgetrf.o): In function `zgetrf_':
zgetrf.f:(.text+0x608): undefined reference to `ztrsm_'
zgetrf.f:(.text+0x6cc): undefined reference to `zgemm_'
lapack_LINUX.a(zgetf2.o): In function `zgetf2_':
zgetf2.f:(.text+0x1a0): undefined reference to `izamax_'
zgetf2.f:(.text+0x214): undefined reference to `zswap_'
zgetf2.f:(.text+0x2a0): undefined reference to `zgeru_'
zgetf2.f:(.text+0x51c): undefined reference to `zscal_'
collect2: ld returned 1 exit status
make: *** [zgetrf] Error 1


Here is the code I used:

Code: Select all
typedef struct {
        double real, imag;
}doublecomplex;

extern zgetrf_( int, int, doublecomplex*, int, int*, int*);

int main() {
   int i;
   int* info;
   int pivot[8];


   doublecomplex a[4*4];
   
   for(i=0;i<4*4;i++) {
      a[i].real=i*1.0; a[i].imag=i*1.0;
   }

   zgetrf_(4,4,a,4,pivot,info);

   return 0;
}


and the command for the compilation:
gcc -Wall zgetrf.c blas_LINUX.a lapack_LINUX.a libg2c.a _o zgetrf -lm -O3


I made a previous test with the function zgemm which was a success. I used the same command for compilation, so it's quiet strange to see that here, it didn't found the definition of "zgemm_" which is needed for this BLAS function.

Any ideas?

NB: I'm using lapack 3.1.1

John.
Mercury
 
Posts: 11
Joined: Wed Aug 01, 2007 8:51 am

Postby Julien Langou » Tue Aug 07, 2007 8:19 am

John,

3 remarks:

  1. Do not call your main zgetrf.c. Call it, example_zgetrf.c or something like this. That's
    really a weird name to have.
  2. When you link with libraries, the order matters. In this particular case, you need
    to swap BLAS and LAPACK. It's first LAPACK then BLAS. Since LAPACK relies on BLAS
    (and BLAS do not rely on LAPACK). The linker goes in the libraries sequentially to find
    what's missing but does not come back in a previous library.
  3. Even if you manage to link and create an executable, you will have a problem at
    runtime. Your variable info is a pointer and there is no space allocated around.
    (This is what the warning is telling you.) I suggest you declare info as an integer,
    and gives the pointer on info ( &info ) to zgetrf_ .

    So something like:
    int info;
    zgetrf_ ( .... , &info );


Julien.
Julien Langou
 
Posts: 835
Joined: Thu Dec 09, 2004 12:32 pm
Location: Denver, CO, USA

Postby Julien Langou » Tue Aug 07, 2007 8:23 am

and a fourth remark, maybe, you want to use a nonsingular matrix

and a fifth remark, pivot only needs to be of size 4

and finally, using only zgetrf for staring with LAPACK is not that easy since
you'll get an LU factorization, maybe you want to start with zgesv. zgesv
solves a linear system of equations using LU factorization, then you can
check that Ax = b.

Good luck,
-julien.
Julien Langou
 
Posts: 835
Joined: Thu Dec 09, 2004 12:32 pm
Location: Denver, CO, USA

Postby Mercury » Wed Aug 08, 2007 2:49 am

Thanks for your help Julien, problem solved ;)

And thank you for the additionnal comments it'll help me for the next steps!
Mercury
 
Posts: 11
Joined: Wed Aug 01, 2007 8:51 am


Return to User Discussion

Who is online

Users browsing this forum: No registered users and 4 guests