我正在使用命令
运行以下程序gcc filename.c -o filename.exe
并显示错误
" AppData / Local / Temp / cc4rF2ac.o:filename.c :(。text + 0xd4):对LAPACKE_dgels的未定义引用' collect2.exe:错误:ld返回1退出状态"
/* Calling DGELS using column-major order */
#include <stdio.h>
#include <stdlib.h>
#include <lapacke.h>
#include <math.h>
lapack_int main (int argc, const char * argv[])
{
double a[5*3] = {1,2,3,4,5,1,3,5,2,4,1,4,2,5,3};
double b[5*2] = {-10,12,14,16,18,-3,14,12,16,16};
lapack_int info,m,n,lda,ldb,nrhs;
int i,j;
m = 5;
n = 3;
nrhs = 2;
lda = 5;
ldb = 5;
info = LAPACKE_dgels(LAPACK_COL_MAJOR,'N',m,n,nrhs,a,lda,b,ldb);
for(i=0;i<n;i++)
{
for(j=0;j<nrhs;j++)
{
printf("%lf ",b[i+ldb*j]);
}
printf("\n");
}
return(info);
}
答案 0 :(得分:1)
你错过了一个图书馆。重新运行GCC添加-llapacke:
gcc filename.c -o filename.exe -llapacke
假设您的库类似于liblapacke.a或liblapacke.so。否则,重新运行添加-lNAME,并在NAME中添加lib文件的名称,而不使用“lib”和“.a”或“.so”。