[英]c++ program compile with LAPACK library
I'm new to c++ programming, I have a c++ code which taken from the internet. 我是C ++编程的新手,我有一个从互联网上获取的C ++代码。 it using LAPACK library I have installed LAPACK and BLAS (I hope installed successfully) 它使用LAPACK库安装了LAPACK和BLAS(我希望安装成功)
:/usr/local/lib$ ls
libblas.a liblapack.a python3.6
program is this, 程序是这个,
#include <iostream>
#include "lapacke.h"
using namespace std;
int main()
{
char TRANS = 'N';
int INFO=3;
int LDA = 3;
int LDB = 3;
int N = 3;
int NRHS = 1;
int IPIV[3] ;
double A[9] = { 1, 2, 3, 2, 3, 4, 3, 4, 1 };
double B[3] = {-4,-1,-2 };
cout << "compute the LU factorization..." << endl << endl;
LAPACK_dgetrf(&N,&N,A,&LDA,IPIV,&INFO);
if(INFO)
{
cout << "solving the system..."<< endl << endl;
}else{
printf("solving the system...");
dgetrs_(&TRANS,&N,&NRHS,A,&LDA,IPIV,B,&LDB,&INFO);
if(INFO)
{
cout << "an error occured : "<< INFO << endl << endl;
}else{
cout << "print the result : {";
int i;
for (i=0;i<N;i++)
{
cout << B[i] << " ";
}
cout << "}" << endl << endl;
}
}
cout << "program terminated." << endl << endl;
return 0;
}
and i try to compile it using this command, 我尝试使用此命令进行编译,
g++ main.cpp -o run -llapack
but this is the output I get, 但这是我得到的输出,
/usr/bin/ld: cannot find -llapack
collect2: error: ld returned 1 exit status
I'm using Ubuntu 18.04 Please help me with this. 我正在使用Ubuntu 18.04,请为此提供帮助。 thank you 谢谢
It sounds like your system isn't set up to search /usr/local/lib for libraries. 听起来您的系统未设置为在/ usr / local / lib中搜索库。
You can add -L/usr/local/lib
to your compile command. 您可以将-L/usr/local/lib
到您的编译命令中。
If you need to install the library, I suggest you use this command: 如果需要安装该库,建议您使用以下命令:
sudo apt-get install liblapack-dev
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.