c++ - Linking error with LAPACK under cygwin -
similar problem described in this question, want compile c++ program using lapack under windows 8.1, using cygwin (and written in netbeans). got necessary packages in cygwin (lapack, liblapack-devel, liblapack0), , have written function prototype:
extern "c" void dgeev_(char* jobvl, char* jobvr, int* n, double* a, int* lda, double* wr, double* wi, double* vl, int* ldvl, double* vr, int* ldvr, double* work, int* lwork, int* info);
but trying compile still throws error linker:
$ g++ -llapack -lblas main.cpp /tmp/cc3opfn5.o:main.cpp:(.text+0x349): undefined reference `dgeev_' /tmp/cc3opfn5.o:main.cpp:(.text+0x403): undefined reference `dgeev_' collect2: error: ld returned 1 exit status
the code looks (adapted this example):
/* locals */ int n = n, lda = lda, ldvl = ldvl, ldvr = ldvr, info, lwork; double wkopt; double* work; double h = k_max / n; /* local arrays */ double wr[n], wi[n], vl[ldvl * n], vr[ldvr * n]; double a[lda * n]; /* initialize matrix */ (int = 0; < n; i++) { (int j = 0; j < n; j++) { a[i * n + j] = integral(i + 1, j + 1); if (i == j) { a[i * n + j] += diagonal((i + 1) * h); } } } /* executable statements */ printf(" dgeev example program results\n"); /* query , allocate optimal workspace */ lwork = -1; char vec[] = "vectors"; dgeev_(vec, vec, &n, a, &lda, wr, wi, vl, &ldvl, vr, &ldvr, &wkopt, &lwork, &info); lwork = (int) wkopt; work = (double*) malloc(lwork * sizeof (double)); /* solve eigenproblem */ dgeev_(vec, vec, &n, a, &lda, wr, wi, vl, &ldvl, vr, &ldvr, work, &lwork, &info);
what missing? :-/
supposing have installed blas
, lapack
libraries correctly , system can locate them, have change order in compile command.
$ g++ main.cpp -llapack -lblas
the compiler should know functions of main.cpp
should libraries before declare them.
Comments
Post a Comment