this is my very first question :)
I guess it is not qualified as should as be but this is what I am working on and It would be very nice to get someones opinion on this.
I am currently working on using LAPACK in a Linux based environment and I am very confused with it. I am trying to use C++ but I can code with Python also. First of all, I don't have root in the HPC, I am connecting to the school’s server, so I am not flexible as much as I need in terms of software.
I can write and compile any other C++ codes that require very basic includes such as string and so on. However, I could not find a way to be able to include necessary things or links with the LAPACK project.
For example: Understanding LAPACK calls in C++ with a simple example
//LAPACK test code
//compile with: g++ main.cpp -llapack -lblas -o testprog
#include <iostream>
#include <vector>
using namespace std;
extern "C" void dgetrf_(int* dim1, int* dim2, double* a, int* lda, int* ipiv, int* info);
extern "C" void dgetrs_(char *TRANS, int *N, int *NRHS, double *A, int *LDA, int *IPIV, double *B, int *LDB, int *INFO );
int main()
{
char trans = 'N';
int dim = 2;
int nrhs = 1;
int LDA = dim;
int LDB = dim;
int info;
vector<double> a, b;
a.push_back(1);
a.push_back(1);
a.push_back(1);
a.push_back(-1);
b.push_back(2);
b.push_back(0);
int ipiv[3];
dgetrf_(&dim, &dim, &*a.begin(), &LDA, ipiv, &info);
dgetrs_(&trans, &dim, &nrhs, & *a.begin(), &LDA, ipiv, & *b.begin(), &LDB, &info);
std::cout << "solution is:";
std::cout << "[" << b[0] << ", " << b[1] << ", " << "]" << std::endl;
std::cout << "Info = " << info << std::endl;
return(0);
}
There is this argument that is really close to what I am trying to do, solve a basic system with LAPACK. When I tried to use that code here is the error that I am facing with:
g++ main.cpp -llapack -lblas -o testprog
/cta/capps/lapack/3.9.0/lib/../lib/liblapack.a(xerbla.f.o): In function `xerbla_':
xerbla.f:(.text+0x49): undefined reference to `_gfortran_st_write'
xerbla.f:(.text+0x54): undefined reference to `_gfortran_string_len_trim'
xerbla.f:(.text+0x69): undefined reference to `_gfortran_transfer_character_write'
xerbla.f:(.text+0x79): undefined reference to `_gfortran_transfer_integer_write'
xerbla.f:(.text+0x81): undefined reference to `_gfortran_st_write_done'
xerbla.f:(.text+0x8a): undefined reference to `_gfortran_stop_string'
collect2: error: ld returned 1 exit status
I really need some advice or source to understand the logic behind the LAPACK and linking it with C++.
Thanks in advance...