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

Some problems with linking

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

Some problems with linking

Postby Mercury » Wed Aug 01, 2007 9:04 am

Hello everyone!

I installed lapack 3.1.1 on a PowerPC (Fedora Core 6). I followed the different steps/tests succesfully (got the blas_LINUX.a and lapack_LINUX.a).
I also installed the libg2c.a manually.

Now here is my problem; I tryed to compile an example code:



Code: Select all
#include <stdio.h>
#define NMAX 1000

extern void dgtsv_(int *, int *,
                   double *, double *, double *, double *,
                   int *, int *);

int main()
{
        int i, n=10, one=1, info;
        double dl[NMAX-1],d[NMAX],du[NMAX-1],b[NMAX];

        for (i=0;i<n-1;i++) {
          dl[i]        =-1.;
          d[i]         = 2.;
          du[i]        =-1.;
          b[i]         = 1.;
        }
        d[n-1]        =2.;
        b[n-1]        =1.;

        dgtsv_(&n,&one,dl,d,du,b,&n,&info);

        if (info==0) {
         for (i=0;i<n;i++) {
           printf(" i %d b(i) %le erreur %le \n",
                          i,b[i],b[i]-(i+1)*(n+1-i-1)/2.);

         }
        }
        return 0;
}


I tryed this:
gcc example.c


and it returned
/tmp/cceayykK.o : In function 'main':
example.c(.text+0x164): undefined reference to 'dgtdv_'


So I tryed:
gcc example.c lapack_LINUX.a


(i made a link to this library in the directory)

and it returned:
lapack_LINUX.a(xerbla.o) : In function 'xerbla_':
xerbla.f ... undefined reference to 's_wsfe'
xerbla.f ... undefined reference to 'do_fio'
xerbla.f ... undefined reference to 'do_fio'
xerbla.f ... undefined reference to 'e_wsfe'
xerbla.f ... undefined reference to 's_stop'


Could someone lend me a hand please?
Mercury
 
Posts: 11
Joined: Wed Aug 01, 2007 8:51 am

Postby Mercury » Wed Aug 01, 2007 11:02 am

In fact I also installed some pre-compiled librairies from Atlas but I don't use its at the moment.

I also tryed to test the lapack's RPM for PPC like this:
gcc example -llapack


And I receive this in return:
[...]/lib/liblapack.so: undefined reference to 'etime_'
[...]/lib/liblapack.so: undefined reference to 's_stop'
[...]/lib/liblapack.so: undefined reference to 's-wsfe'
[...]/lib/liblapack.so: undefined reference to 'r_lg10'
[...]/lib/liblapack.so: undefined reference to 's_cmp'
[...]/lib/liblapack.so: undefined reference to 'e_wsfr'
[...]/lib/liblapack.so: undefined reference to 'z_abs'
[...]/lib/liblapack.so: undefined reference to 'z_sqrt'
[...]/lib/liblapack.so: undefined reference to 's_cat'
[...]/lib/liblapack.so: undefined reference to 'c_sqrt'
[...]/lib/liblapack.so: undefined reference to 's_copy'
[...]/lib/liblapack.so: undefined reference to 'pow_dd'
[...]/lib/liblapack.so: undefined reference to 'do_fio'
[...]/lib/liblapack.so: undefined reference to 'z_exp'
[...]/lib/liblapack.so: undefined reference to 'c_abs'
[...]/lib/liblapack.so: undefined reference to 'c_exp'
[...]/lib/liblapack.so: undefined reference to 'd_lg10'


if I try :
gcc example -llapack -lblas

or (since I read somewhere that order is important):
gcc example -lblas -llapack


nothing change (still the same errors)
:(
Mercury
 
Posts: 11
Joined: Wed Aug 01, 2007 8:51 am

Postby Julie » Wed Aug 01, 2007 11:09 am

Mercury
gcc example -lblas -llapack

The order is first LAPACK then BLAS library.
Just add -lg2c -lm and it should work:
Code: Select all
gcc example  -llapack -lblas -lg2c -lm

Julie
Julie
 
Posts: 299
Joined: Wed Feb 23, 2005 12:32 am
Location: ICL, Denver. Colorado

Postby Mercury » Thu Aug 02, 2007 3:03 am

The compilation is done thank you julie!

now I got 2 others questions:

1. I used a link to the libg2c.a file since gcc can't recognize the "-lg2c" link. Do you know how to make this "-lg2c" operationnal instead of my poor trick?

2. Compilation is allright but... the program gave me a segmentation fault. Was wondering if it was the programm which got a problem or *erm* something else. Could someone lend me a small "test code" like the one I gave upper? I saw some code sticked on the forum but it was in FORTRAN, not in C.
Mercury
 
Posts: 11
Joined: Wed Aug 01, 2007 8:51 am

Postby Mercury » Thu Aug 02, 2007 3:14 am

*erm* I tested this program:

Code: Select all
int main() {
   return 0;
}


then compiled it:
gcc test.c -llapack -lblas libg2c.a -lm


and it gave me a segmentation fault too :cry:

when I try:
gcc test.c -llapack libg2c.a


I got the same problem (since I can't use lapack library without libg2c.a, seems like one of them isn't working?)
Mercury
 
Posts: 11
Joined: Wed Aug 01, 2007 8:51 am

Postby Mercury » Thu Aug 02, 2007 3:22 am

I found the problem:

when I use -llapack it take its from the lapack RPM's package I installed, not the one from ATLAS. Added the link to lapack and blas from ATLAS and it's working!
Mercury
 
Posts: 11
Joined: Wed Aug 01, 2007 8:51 am

Postby Mercury » Thu Aug 02, 2007 3:57 am

hello again!

I'm now trying to use cblas_* function from the ATLAS library. I tryed to compile a program which use cblas_zgemm function but when I compile it:
gcc program.c liblapack.a libcblas.a libg2c.a -lm


it return:
libcblas.a(cblas_zgemm.o): in function 'cblas_zgemm':
cblas_zgemm.c:(.text+0x170): undefined reference to 'ATL_zgemm'


I don't know where this ATL_X can be found.
Mercury
 
Posts: 11
Joined: Wed Aug 01, 2007 8:51 am

Postby Julien Langou » Thu Aug 02, 2007 10:20 am

I think you need to add libatlas.a between liblapack.a and libg2c.a
Julien.
Julien Langou
 
Posts: 835
Joined: Thu Dec 09, 2004 12:32 pm
Location: Denver, CO, USA

Postby Mercury » Fri Aug 03, 2007 2:26 am

Seems like it's working now, thank you very much!
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