gpt4 book ai didi

eclipse - 在 Ubuntu 中连接 LAPACKE 和 Eclipse

转载 作者:行者123 更新时间:2023-12-04 18:52:43 24 4
gpt4 key购买 nike

我是 C++ 新手,我正在使用 Eclipse 编写脚本。我的操作系统是 Ubuntu。我需要为我的代码部分使用 LAPACKE 包。然而,我无法设法链接 Eclipse 和 LAPACKE。我正在尝试编译以下示例代码:

#include <stdio.h>
#include <lapacke.h>

int main (int argc, const char * argv[])
{
double a[5][3] = {1,1,1,2,3,4,3,5,2,4,2,5,5,4,3};
double b[5][2] = {-10,-3,12,14,14,12,16,16,18,16};
lapack_int info,m,n,lda,ldb,nrhs;
int i,j;

m = 5;
n = 3;
nrhs = 2;
lda = 3;
ldb = 2;

info = LAPACKE_dgels(LAPACK_ROW_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][j]);
}
printf("\n");
}
return(info);
}

我无法编译代码,因为我的 Eclipse 抛出错误:“Udefined reference to LAPACKE_dgels”。我试图将 Eclipse 链接到 LAPACKE,为此我在 Eclipse 的“路径和符号”选项卡中添加了 LAPACKE 头文件的路径。任何人都可以帮助我解决这个问题需要做些什么吗?我应该错过一些东西......

最佳答案

我假设您正在使用 gcc 编译器。我猜你不见了-llapack编译参数中的标志。如果不起作用,请尝试 -llapacke .这个标志(-l[LibraryName])告诉链接器使用外部二进制文件(见:gcc: Difference between -L and -l option AND how to provide complete path to a library)。
查看此问题以了解如何在 Eclipse 中添加编译器标志:How to add compiler options in Eclipse IDE

关于eclipse - 在 Ubuntu 中连接 LAPACKE 和 Eclipse,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21945235/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com