problem linking to lapack atlas

44 views
Skip to first unread message

albert

unread,
Jun 28, 2009, 11:00:10 AM6/28/09
to gg95
Hi, I'm new to g95 and Fortran. I'm having a few problems linking. I
wrote a small test program to test linking to precompiled lapack blas
libraries I downloaded from the SciPy website:
I followed instructions from this thread:

http://groups.google.as/group/gg95/browse_thread/thread/62f346a53e9c3b37/1000c405829a76de?lnk=gst&q=atlas+lapack#1000c405829a76de

The libraries I found here:

http://www.scipy.org/Installing_SciPy/Windows#head-cd37d819e333227e327079e4c2a2298daf625624

The following is my test code:

program testblas

external DGEMM

integer, parameter :: rd = SELECTED_REAL_KIND(15,307)
real(kind=rd),dimension(2,2) :: a,b,c
c=0.0
a(1,1)=1.1
a(1,2)=1.3
a(2,1)=1.7
a(2,2)=1.5

b(1,1)=1.6
b(1,2)=1.7
b(2,1)=1.8
b(2,2)=1.3

call DGEMM ( 'n','n', 2, 2, 2, 1.0_rd, a, 2, b, 2, 0.0_rd, c, 2 )

print*, c

end program testblas

I then compile and link with the following commands:
D:\Fortran\testblas>g95 -o testblas.exe testblas.f95 -llapack -
lf77blas -lcblas -latlas -lg2c

However I get the following error message:

D:\Fortran\testblas>g95 -o testblas.exe testblas.f95 -llapack -
lf77blas -lcblas
-latlas -lg2c
c:/programme/g95/bin/../lib/gcc-lib/i686-pc-mingw32/4.0.4//libg2c.a
(main.o):(.te
xt+0x38): undefined reference to `_MAIN__'

The libraries are in the lib directory of my g95 installation. the
paths are set.

I'm using i686-pc-mingw32 4.0.4

Any ideas anyone?

Best regards

Albert

Adelson Santos de Oliveira

unread,
Jun 28, 2009, 5:01:32 PM6/28/09
to gg...@googlegroups.com
Some compilers append a _ to subroutines, some append two __. Maybe this
is the cause for linking problems. If so, either recompile lapack and
blas with g95 or
look for some way to tell g95 to understand that.

albert escreveu:

John McFarland

unread,
Jun 29, 2009, 10:29:14 AM6/29/09
to gg95
On Jun 28, 10:00 am, albert <acp...@hotmail.com> wrote:
> D:\Fortran\testblas>g95 -o testblas.exe testblas.f95 -llapack -
> lf77blas -lcblas
> -latlas -lg2c
> c:/programme/g95/bin/../lib/gcc-lib/i686-pc-mingw32/4.0.4//libg2c.a
> (main.o):(.te
> xt+0x38): undefined reference to `_MAIN__'
> Any ideas anyone?
>
> Best regards
>
> Albert

Try using different orderings of the libraries. Also what happens if
you leave off -lg2c? Do you need -lcblas?

John

albert

unread,
Jun 30, 2009, 2:21:14 AM6/30/09
to gg95
Thanks John and Albert,

still no success in getting this to work. I tried the following:
>g95 -fno-leading-underscore -fno-underscoring -o testblas testblas.f95 -lf77blas -latlas
C:\DOKUME~1\FI~1\LOKALE~1\Temp/ccuhPmhO.o:testblas.f95:(.text+0x1ee):
undefi
ned reference to `_dgemm'

if I leave out the -fno-underscoring then the error message becomes:
undefined reference to _dgemm_

so why doesn't -fno-leading-underscore suppress the leading
underscore?

Any ideas?

regards Albert

李波

unread,
Jul 1, 2009, 1:50:59 AM7/1/09
to gg95
Dear albert
 
  I think you can change the order of your link-libraries. Because f77blas is the basic
library, so it must be put the last position. Maybe you try:
 
 
g95 -fno-leading-underscore -fno-underscoring -o testblas testblas.f95  -latlas -lf77blas 
 
 
2009-07-01

李波

发件人: albert
发送时间: 2009-06-30  14:21:22
收件人: gg95
抄送:
主题: Re: problem linking to lapack atlas

albert

unread,
Jul 2, 2009, 12:55:31 AM7/2/09
to gg95
Thank you, I tried reordering the libraries in the manner you suggest
but I still get the same error message:

C:\DOKUME~1\FI~1\LOKALE~1\Temp/cc8Ln7JK.o:testblas2.f95:(.text+0x13d):
undef
ined reference to `_dgemm'

maybe these libraries aren't compatible with g95.

Regards Albert



On Jul 1, 7:50 am, "李波" <libo...@sohu.com> wrote:
> Dear albert
>
>   I think you can change the order of your link-libraries. Because f77blas is the basic
> library, so it must be put the last position. Maybe you try:
>
> g95 -fno-leading-underscore -fno-underscoring -o testblas testblas.f95  -latlas -lf77blas
>
> 2009-07-01
>
> 李波

John McFarland

unread,
Jul 8, 2009, 12:03:11 PM7/8/09
to gg95
Albert,

I am almost certain that your problem is not an underscore issue, but
a library/linking issue. The library g2c provides compatibility for
BLAS and LAPACK when linking with a C compiler. However, you are
linking with g95, which is not a C compiler, so you should not need to
link against g2c. I'm not too sure what the cblas library is, but it
sounds like it might be a C-interface to BLAS, in which case you
probably don't need to link it.

Also are you doing this under cygwin? If so, the easiest thing would
be to just install cygwin's own lapack library. When you install
that, it will also give you a BLAS library. The installed files are
listed here:
http://cygwin.com/cgi-bin2/package-cat.cgi?file=lapack%2Flapack-3.0-5&grep=blas

Then since your example only uses a BLAS routine, you should be able
to link with "-lblas". If you later add lapack routines to your code,
you could link with "-llapack -lblas".

John

albert

unread,
Jul 14, 2009, 1:49:23 PM7/14/09
to gg95
Thanks John for looking at this. I particularly wanted an optimised
Blas/Lapack library, I think the problem lies in the fact that I was
trying to use binaries that probably weren't compiled with g95.
Following the build instructions on the Atlas site to build the
libraries from scratch using g95 doesn't seem that straight forward
either.

Regards

Albert

On Jul 8, 6:03 pm, John McFarland <john.mcfarl...@swri.org> wrote:
> Albert,
>
> I am almost certain that your problem is not an underscore issue, but
> a library/linking issue.  The library g2c provides compatibility for
> BLAS and LAPACK when linking with a C compiler.  However, you are
> linking with g95, which is not a C compiler, so you should not need to
> link against g2c.  I'm not too sure what the cblas library is, but it
> sounds like it might be a C-interface to BLAS, in which case you
> probably don't need to link it.
>
> Also are you doing this under cygwin?  If so, the easiest thing would
> be to just install cygwin's own lapack library.  When you install
> that, it will also give you a BLAS library.  The installed files are
> listed here:http://cygwin.com/cgi-bin2/package-cat.cgi?file=lapack%2Flapack-3.0-5...
Reply all
Reply to author
Forward
0 new messages