questions when linking clapack lib to object files.

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

questions when linking clapack lib to object files.

Postby ivanbbq » Fri Mar 04, 2005 6:28 pm

When I want to link the libraries of clapack to the object files by gcc on unix, the following error arises
-----------------------------------------------
gcc projectEx.o BlkLanAux.o tmglib_SUN4SOL2.a blas_SUN4SOL2.a lapack_SUN4SOL2.a
Undefined first referenced
symbol in file
log lapack_SUN4SOL2.a(zlarnv.o)
sqrt lapack_SUN4SOL2.a(zlange.o)
s_cmp lapack_SUN4SOL2.a(ilaenv.o)
z_abs lapack_SUN4SOL2.a(zlange.o)
z_div blas_SUN4SOL2.a(ztrsm.o)
z_exp lapack_SUN4SOL2.a(zlarnv.o)
f2c_dznrm2 lapack_SUN4SOL2.a(zlarfg.o)
d_cnjg blas_SUN4SOL2.a(zgemm.o)
d_imag lapack_SUN4SOL2.a(zlassq.o)
d_sign lapack_SUN4SOL2.a(zlarfg.o)
do_fio blas_SUN4SOL2.a(xerbla.o)
e_wsfe blas_SUN4SOL2.a(xerbla.o)
f2c_zdscal lapack_SUN4SOL2.a(zlarfg.o)
pow_di lapack_SUN4SOL2.a(dlamch.o)
s_copy lapack_SUN4SOL2.a(ilaenv.o)
s_stop blas_SUN4SOL2.a(xerbla.o)
s_wsfe blas_SUN4SOL2.a(xerbla.o)
f2c_zgemv lapack_SUN4SOL2.a(zlarft.o)
f2c_zgerc lapack_SUN4SOL2.a(zlarf.o)
f2c_zcopy lapack_SUN4SOL2.a(zlarfb.o)
f2c_ztrmm lapack_SUN4SOL2.a(zlarfb.o)
f2c_ztrmv lapack_SUN4SOL2.a(zlarft.o)
f2c_zscal lapack_SUN4SOL2.a(zlarfg.o)
ld: fatal: Symbol referencing errors. No output written to a.out
collect2: ld returned 1 exit status

-----------------------------------------------------

it seems like the functions in the left column are missing which are called by the object files in the right column.
Where are the functions? are there any files containing them that i should also link to the program?

thx for helping.
ivanbbq
 
Posts: 1
Joined: Fri Mar 04, 2005 6:18 pm

Postby Stan Tomov » Mon Mar 07, 2005 2:11 am

Most of the undefined symbols that you get are defined in library
libg2c.a, which is part of the gcc distribution (for example, on my
machine this is in /usr/lib/gcc/i386-redhat-linux/3.4.2/).
Try to link with that library. You also may need some other libraries
like libm.a, etc. I hope this will help.
Stan
Stan Tomov
 
Posts: 13
Joined: Thu Dec 09, 2004 1:28 pm

Postby Julie » Thu Mar 10, 2005 11:44 am

Ivan,

The first thing to do is to check the compile line in the CLAPACK/TESTING or CLAPACK/TIMING subdirectories. Just type 'make' in the CLAPACK/TESTING, note the compile line.
For example, you will see in the CLAPACK/TESTING/LIN/Makefile the following line:
Code: Select all
../xlintsts : $(ALINTST) $(SLINTST) $(SCLNTST)
      $(LOADER) $(LOADOPTS)  $(ALINTST) $(SCLNTST) $(SLINTST) \
      ../../$(TMGLIB) ../../$(LAPACKLIB) $(BLASLIB) $(F2CLIB) -lm -lc \
      -o $@

where TMGLIB and LAPACKLIB are built in the distribution, BLASLIB is the BLAS library you want to use for the tests, and F2CLIB is libF77.a and libI77.a.
and check that the compilation runs correctly!

If the compilation is successful, you can use the same compile line (without tmglib_LINUX.a): that should look like that:
Code: Select all
gcc -o test test.c  $CLAPACKDIR/lapack_LINUX.a $CLAPACKDIR/libfblaswr.a $CLAPACKDIR/blas_LINUX.a $CLAPACKDIR/F2CLIBS/libF77.a $CLAPACKDIR/F2CLIBS/libI77.a -lm

where $CLAPACKDIR is set to your CLAPACK directory.

The correct linking sequence is: lapack, fblaswr, blas, F77 and I77.

Note that:
    - if you are using the blas (in fact cblas) GIVEN in the clapack package (that seems to be the case). You have to modify the make.inc to add the option -DNO_BLAS_WRAP
    to CFLAGS and NOOPT in make.inc.( Do not forget to recompile CLAPACK: 'make clean' then 'make blaslib' and 'make'. ) The link sequence should then be something like:
    Code: Select all
    gcc -o test test.c  $CLAPACKDIR/lapack_LINUX.a $CLAPACKDIR/blas_LINUX.a $CLAPACKDIR/F2CLIBS/libF77.a $CLAPACKDIR/F2CLIBS/libI77.a -lm

    The libfblaswr.a is not anymore be needed.

    - if you want to use the blas of your machine (which is good for performance), the libfblaswr.a is then mandatory!!! If you don't have libfblaswr.a in your CLAPACK directory, you can generate it with the 'make fblaswrap' command. To test CLAPACK with an optimized BLAS of your machine, modify the BLASLIB variable from your make.inc and run the tests again.

Let me know, if this solves your problem.

Finally
another way to go is to use the LAPACK library (in Fortran 77) available at
http://www.netlib.org/lapack/lapack.tgz .
You may then link the LAPACK library to your C code using gcc by doing for example
Code: Select all
gcc -c test.c
gcc -o test test.o -L/usr/local/lib -llapack -lblas -lg2c -lm


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


Return to User Discussion

Who is online

Users browsing this forum: No registered users and 5 guests