>From: Christoph Groth [mailto:cwg@...]
>Sent: 19. maaliskuuta 2012 17:04
>Subject: [Mingw-users] _imp__ prefixes when linking
>We are experiencing a problem while trying to link a library compiled with
MinGW: We need to link against the LAPACK >and BLAS libraries and this works
without problems on unix-like platforms. With MinGW, however, we get many
errors >like this:
>"undefined reference to '_imp__strevc_'"
>"strevc" is a LAPACK routine which should be present in one of the
libraries we link against.
>These errors appear in two different cases:
>(1) Trying to link against libraries downloaded from
>(2) Trying to link against BLAS and LAPACK compiled with MinGW on the
> same machine. (This has been tried by a colleague and not myself.)
>I understand that the _imp__ prefix is normally used for functions which
are present in a small static library. The >_imp__ functions then call the
real routines in a DLL.
>However, in case (1), there is no DLL but only large static libraries.
>Thank you in advance for suggestions on how to deal with this problem.
>Can someone perhaps even recommend the best way to use LAPACK/BLAS under
Windows with MinGW? (Compile it from source? >Use binaries? Which?)
1) Both BLAS and LAPACK 3.4.0 should compile with MinGW out of the box:
tar xvfz lapack-3.4.0.tgz
cp make.inc.example make.inc
This should produce two static libs: librefblas.a and liblapack.a
If the reference implementation of BLAS is not fast enough for your
you might consider replacing it e.g. with ATLAS (not worth the trouble in
2) The error message "undefined reference to '_imp__strevc_'" is most
due to the presence of __declspec(import) attribute in front of the
strevc() in one of your project header files, as already pointed out by Eli
If so, you can just remove that attribute when linking against the static
Another possibility is to create a dll from the static libs. The link you
explains how to do this with gcc. The following modified line works with
and liblapack.a, producing the combined import library blaslapack.lib and
gcc -shared -o blaslapack.dll -Wl,--out-implib=blaslapack.lib
-Wl,--allow-multiple-definition -Wl,--enable-auto-import -Wl,--whole-archive
librefblas.a -Wl,--no-whole-archive -lgfortran
Now, link your application against blaslapack.lib and put blaslapack.dll
somewhere in PATH.