使用 dgesv_ 时出错:C:..眼动仪.exe未找到
Error when using dgesv_: C:...Eye Tracker.exe not found
我正在尝试使用dgesv_函数解决一个简单的问题Ax = b。但是,我遇到了一个我无法解决的问题。我的代码是:
#include <cstdio>
#include <f2c.h>
#include <clapack.h>
void main(void)
{
/* 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};
int N = 3;
int nrhs = 1;
int lda = 3;
int ipiv[3];
int ldb = 3;
int info;
dgesv_(&N, &nrhs, A, &lda, ipiv, b, &ldb, &info);
}
我认为代码是正确的,但是,每当我运行它时,我都会收到以下错误:
LINK : C:...Eye Tracker.exe not found or not built by the last incremental link; performing full link
1> Creating library C:...Eye TrackerDebugEye Tracker.lib and object C:UsersDanieldocumentsvisual studio 2010ProjectsEye TrackerDebugEye Tracker.exp
1>ellipse_fit.obj : error LNK2019: unresolved external symbol "void __cdecl dgesv_(int const *,int const *,double *,int const *,int *,double *,int const *,int *)" (?dgesv_@@YAXPBH0PAN0PAH102@Z) referenced in function "void __cdecl ttt(void)" (?ttt@@YAXXZ)
1>C:UsersDanieldocumentsvisual studio 2010ProjectsEye TrackerDebugEye Tracker.exe : fatal error LNK1120: 1 unresolved externals
您的错误可能来自 LAPACK 未链接到您的程序。CLAPACK 很容易链接到 C 程序,但链接到 C++ 需要添加几行。根据 http://wwwx.cs.unc.edu/~cquammen/wp/2010/08/12/calling-clapack-code-from-c/以下行应该可以解决问题:
extern "C" {
#include <f2c.h>
#include <clapack.h>
}
如果还不够,这里有一段可以通过g++ main.cpp -o main -llapack -lblas -lm
编译的代码:
#include <iostream>
using namespace std;
extern "C"
{
void dgesv_(int* n,int* nrhs,double* a,int* lda,int* ipiv, double* b,int* ldb,int* info);
}
int main(void)
{
/* 3x3 matrix A
* 76 25 11
* 27 89 51
* 18 60 32
*/
double A[9] = {1, 0, 0, 0, 2, 0, 0, 0,4};
double b[3] = {42, 84, 168};
int N = 3;
int nrhs = 1;
int lda = 3;
int ipiv[3];
int ldb = 3;
int info;
dgesv_(&N, &nrhs, A, &lda, ipiv, b, &ldb, &info);
cout<<"solution : "<<b[0]<<" "<<b[1]<<" "<<b[2]<<endl;
}
相关文章:
- 访问者访问变体并返回不同类型时出错
- 为cl.exe(Visual Studio代码)指定命令行C++版本
- 在Linux for Windows上编译C++代码时出错
- 读取文件的最后一行并输入到链接列表时出错
- 重载操作程序时出错>>用于类中的字符串 memebr
- 调用专用模板时出错"no matching function for call to [...]"
- C++-试图将函数指针推回到另一个CPP文件中的矢量时出错
- LINK 尝试使用 OpenSSL evp aes 256 c++ 时出错
- 在Google Kick start中提交时出错
- 在c++中访问int到类对象的映射时出错
- 终端不会为C++文件创建.exe文件吗
- 分段错误当我试图运行程序时出错
- 在Windows中以.exe的形式运行c++
- 使用dynamic_cast和构造函数时出错
- CHECK(调用)函数在Google Colab中出错
- 用pybind11包装C++抽象类时出错
- PrintWindow函数在notepad.exe中出错
- 从 Qt(release) 生成的文件执行.EXE文件时出错
- 在另一台计算机上打开 Visual Studio 项目的.exe时出错
- 使用 dgesv_ 时出错:C:..眼动仪.exe未找到