OONumerics User : |
From: Evgenii Rudnyi (rudnyi_at_[hidden])
Date: 2005-01-25 05:17:33
> I am trying to link a C++ program to LAPACK but I have not been
> successful. I understand how to call FORTRAN functions from C++ but
> cannot link successfully. My development environment is Dev-C++
> (http://www.bloodshed.net/devcpp.html).
>
> 1. Where can I find a reliable, up-to-date (precompiled) Windows
> LAPACK library?
To compile LAPACK is not a big deal - edit make.inc and run make.
Yet, the most crucial part for performance is BLAS. I think that there
is precompiled ATLAS at http://math-atlas.sourceforge.net/. But then
you should change a bit the LAPACK library (see instruction at the
ATLAS cite).
To compile ATLAS is much more tricky business.
Alternatively, you can buy already compiled libraries. I think, Intel
has something in this respect.
> 2. How do I link to such a LAPACK library on a Windows platform (using
> Dev-C++)?
In principle, this is the same way as you link with other libraries.
The trick is that a name that a Fortran compiler give to a subroutine
may be different from what you expect. Say, quite often, a Fortran
compiler add more underscores.
So what should you do first is to look how Lapack routines are called
in your library. To learn this use nm on Unix, on Windows I do not know
what.
When you know how the subroutine is called within the library, adjust
its name in your code. Do not forget that a C compiler add a single
underscore, a C++ compiler makes name mangling, so you should use
extern "C" to escape it.
I have examples on how to call Lapack from C++ with gcc at my site.
Look at tdlib.
A nice paper about linking:
THE INSIDE STORY ON
SHARED LIBRARIES AND DYNAMIC LOADING
By David M. Beazley, Brian D. Ward, and Ian R. Cooke
COMPUTING IN SCIENCE & ENGINEERING, SEPTEMBER/OCTOBER 2001
Best wishes,
Evgenii
-- http://Evgenii.Rudnyi.Ru/