0

I would like to use the levmar libraries on MacOS X Mojave. In order to compile the libraries I had to first compile the f2c libraries which goes without an error and then use that for the compilation of levmar libraries via cmake. All these compile without an error and also the crerated example demo program 'lmdemo' actually runs. However when I try to compile the expfit.c example (which comes with the levmar download) using g++ I get an error:

Undefined symbols for architecture x86_64: "dgemm", referenced from: _dlevmar_trans_mat_mat_mult in liblevmar.a(misc.c.o) "dgeqrf", referenced from: _dAx_eq_b_QR in liblevmar.a(Axb.c.o) _dAx_eq_b_QRLS in liblevmar.a(Axb.c.o) "dgesvd", referenced from: _dAx_eq_b_SVD in liblevmar.a(Axb.c.o) _dlevmar_pseudoinverse in liblevmar.a(misc.c.o) "dgetrf", referenced from: _dAx_eq_b_LU in liblevmar.a(Axb.c.o) "dgetrs", referenced from: _dAx_eq_b_LU in liblevmar.a(Axb.c.o) "dorgqr", referenced from: _dAx_eq_b_QR in liblevmar.a(Axb.c.o) "dpotf2", referenced from: _dlevmar_chol in liblevmar.a(misc.c.o) "dpotrf", referenced from: _dAx_eq_b_Chol in liblevmar.a(Axb.c.o) "dpotrs", referenced from: _dAx_eq_b_Chol in liblevmar.a(Axb.c.o) "dsytrf", referenced from: _dAx_eq_b_BK in liblevmar.a(Axb.c.o) "dsytrs", referenced from: _dAx_eq_b_BK in liblevmar.a(Axb.c.o) "dtrtrs", referenced from: _dAx_eq_b_QR in liblevmar.a(Axb.c.o) _dAx_eq_b_QRLS in liblevmar.a(Axb.c.o) "sgemm", referenced from: _slevmar_trans_mat_mat_mult in liblevmar.a(misc.c.o) "sgeqrf", referenced from: _sAx_eq_b_QR in liblevmar.a(Axb.c.o) _sAx_eq_b_QRLS in liblevmar.a(Axb.c.o) "sgesvd", referenced from: _sAx_eq_b_SVD in liblevmar.a(Axb.c.o) _slevmar_pseudoinverse in liblevmar.a(misc.c.o) "sgetrf", referenced from: _sAx_eq_b_LU in liblevmar.a(Axb.c.o) "sgetrs", referenced from: _sAx_eq_b_LU in liblevmar.a(Axb.c.o) "sorgqr", referenced from: _sAx_eq_b_QR in liblevmar.a(Axb.c.o) "spotf2", referenced from: _slevmar_chol in liblevmar.a(misc.c.o) "spotrf", referenced from: _sAx_eq_b_Chol in liblevmar.a(Axb.c.o) "spotrs", referenced from: _sAx_eq_b_Chol in liblevmar.a(Axb.c.o) "ssytrf", referenced from: _sAx_eq_b_BK in liblevmar.a(Axb.c.o) "ssytrs", referenced from: _sAx_eq_b_BK in liblevmar.a(Axb.c.o) "strtrs", referenced from: _sAx_eq_b_QR in liblevmar.a(Axb.c.o) _sAx_eq_b_QRLS in liblevmar.a(Axb.c.o) ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

These seems to be coming from BLAS/LAPACK routine arent they? How come the 'lmdemo' example runs well?

g++ compiler gives this reult for the -v option:

Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/c++/4.2.1 Apple LLVM version 10.0.0 (clang-1000.11.45.5) Target: x86_64-apple-darwin18.2.0 Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

googleing the problem and use the solution of xcode-select --install did not resolve the problem.

Can anyone help me please? Thanks Z

Zolo
  • 27
  • 8

1 Answers1

0

Ok, so it seems that it is not enough to link the levmar (-llevmar) libraries when compiling but also the BLAS and LAPACK libraries (-lblas -llapack). After adding these links the example expfit.c compiles and runs as intended. I am n ot sure I understand this since the program expfit.c does not directly use any blas or lapack routines only levmar does. Does this mean levmar was compiled without blas or lapack? Hmmm...

Zolo
  • 27
  • 8
  • Even if I force the comilation of liblevmar with the static libraries of BLAS and LAPACK I get this error. I am getting confussed about static linking. doesnt it mean that liblevmar then has all the required object file at hand i.e it does not need linking to it again? – Zolo Jan 06 '19 at 10:30