我有一个像 PardisoSolver.h 这样的常规 C++ 类:
#ifndef PARDISOSOLVER_H_
#define PARDISOSOLVER_H_
class PardisoSolver {
public:
/* Initializes a new Solver with the given matrix in CSR */
PardisoSolver(
int* ia,
int* ja,
double* a,
int n,
int nja);
virtual ~PardisoSolver();
void setMatrixType(int mtype);
void pardisoSymFactorize();
private:
static int get_nproc(void);
void handle_error(int ierror, int line);
int* ia; // row indices
int* ja; // column pointer
double* a; // non zero values
int n_eq; // size of matrix
int nja; // number of non zero elements
bool factorized;
/* PARDISO SETTINGS */
void *pt[64];
int maxfct;
int mnum;
int mtype;
int perm;
int nrhs;
int iparm[64];
int msglvl;
int error;
double dparm[64];
double dzero;
int izero;
};
#endif /* PARDISOSOLVER_H_ */
另一方面,我在 PardisoSolver.cpp 中有实现。在这里,我有一个 C 函数的附加声明以及类的实现:
extern "C" void pardiso (void *, int *, int *, int *, int *, int *,
double *, int *, int *, int *, int *, int *,
int *, double *, double *, int *, double *);
现在,当我尝试调用该函数时
pardiso (pt, &maxfct, &mnum, &mtype, &phase,
&n_eq, a, ia, ja, &izero, &nrhs,
iparm, &msglvl, &dzero, &dzero, &error, dparm);
我得到编译错误
PardisoSolver.cpp:94: undefined reference to `pardiso'
调用在第 94 行的位置。我是否在错误的位置声明了 C 函数?据我所知,它不能是一个类的成员,所以这应该是调用它的方式。谢谢您的帮助。