我在从C ++调用LAPACK驱动程序时遇到问题。 以下是一段调用dgesv的简单代码,取自: http://www.cs.rochester.edu/~bh/cs400/using_lapack.html稍作调整。代码编译时没有任何警告/错误,但在运行时崩溃而没有报告任何错误。值得注意的是,如果我注释掉对dgesv的调用,代码将运行完成。
我已经尝试了一些预编译的LAPACK&用于Windows 64位的BLAS库,我得到了相同的行为。我也尝试过从源代码编译库,我也有同样的行为。
我在Windows 10 64位计算机上使用Eclipse中的MinGW64 g ++进行编译。 请帮忙!
#include <cstdio>
typedef int custom_int;
extern "C" void dgesv_(const custom_int *N, const custom_int *nrhs, double *A, const custom_int *lda, custom_int* ipiv, double *b, const custom_int *ldb, custom_int *info);
int main () {
// *********************************************************
// Testing basic linear algebra operations...
// *********************************************************
/* 3x3 matrix A
* 76 25 11
* 27 89 51
* 18 60 32
*/
double A[9] = {76, 27, 18, 25, 89, 60, 11, 51, 32};
double b[3] = {10, 7, 43};
custom_int N = 3;
custom_int num_rhs = 1;
custom_int lda = 3;
custom_int ipiv[3];
custom_int ldb = 3;
custom_int info;
// call lapack linear systems of equation solver...
dgesv_(&N, &num_rhs, A, &lda, ipiv, b, &ldb, &info);
//print results
printf("\n");
if(info == 0) /* succeed */
printf("The solution is %lf %lf %lf\n", b[0], b[1], b[2]);
else
printf("dgesv fails %d\n", info);
return 0;
}
这是我从调试器控制台看到的内容:
GNU gdb (GDB) 7.11.1
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-w64-mingw32".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
No symbol table is loaded. Use the "file" command.
No symbol table is loaded. Use the "file" command.
[New Thread 8748.0x19cc]
[New Thread 8748.0x12b4]
[New Thread 8748.0x17a0]
[New Thread 8748.0x1568]
[Thread 8748.0x12b4 exited with code 3221225781]
[Thread 8748.0x1568 exited with code 3221225781]