On my previous post, I posted how to compile levmar 2.5 with visual studio 2010. Since the procedure mentioned there is not enough to compile levmar 2.6, I write how to solve the compilation issue even though the chips is written on levmar FAQ.
- link error of LAPACK lib files
CmakeLists.txt of levmar 2.6 assumes that you put all lapack related .lib files into one directory. In Cmake GUI, it’s called LAPACKBLAS_DIR that is pre-defined as ‘/usr/lib’. If you compile clapack by yourself, the lib files are generated in different directories not in a directory. To use original CmakeLists.txt, you should put the .lib files into one directory and set LAPACKBLAS_DIR on Cmake GUI. Then, link problem should be solved.
- Link error related to sgemm and dgemm
You may face another link error with the generated solution file. The error is like:
levmar.lib(misc.obj) : error LNK2019: unresolved external symbol _sgemm_ referenced in function _slevmar_trans_mat_mat_mult
levmar.lib(misc.obj) : error LNK2019: unresolved external symbol _dgemm_ referenced in function _dlevmar_trans_mat_mat_mult
This problem is mentioned in levmar FAQ 27. Following the FAQ, I could compile levmar and run the example program. What I did was:
- Uncomment the line 31 of ”#define LM_BLAS_PREFIX f2c_”.
- Comment out the line 37 of “#define LM_BLAS_SUFFIX _ ”
- Uncomment the line 35 of “#define LM_BLAS_SUFFIX”.
Next, I compiled levmar with HAVE_LAPACK option. Then, the compilation was successfully done.
- Necessary .h file and .lib files
After that, I could compile the expfit.c with some modification. What I did was to specify the include file “levmar.h” and library files “blas.lib”, “lapack.lib”, “tmglib.lib”, “libf2c.lib”, and “levmar.lib”.