MATLAB: Question regarding an error when building a mex file for Levenberg-Marquardt algorithm: ERROR: ‘/Applicat​ions/MATLA​B_R2015a.a​pp/bin/mac​i64: No such file or directory’ – even though there is

levenberg marquardtmexmex compiler

Hi there,
I'm trying to build a mex file from a Levenberg-Marquardt algorithm written in C by Manolis Lourakis ( Available here). I've done a lot of searching and haven't been able to find a similar problem or a solution to this yet (lots from this forum!).
The author included a C gateway function and I've managed to solve the errors I was getting from the makefile. Now, when I try to build the makefile I am presented with the following error:
/var/folders/w6/c4f9x2qn7zb2srs97ngpvflh0000gn/T//mex_112796979375_74657:
line 2: -L/Applications/MATLAB_R2016b.app/bin/maci64: No such file or directory
Error using mex The command '/usr/bin/xcrun' exited with a return value '0'
Which seems to say that /Applications/MATLAB_R2016b.app/bin/maci64, is not a path to the file 'maci64'. This is strange as when you follow the path, this file is definitely there. The code I used to build the file was used as instructing in the README file:
mex -DHAVE_LAPACK -I.. -O -L</Users/martinmackinnon/Documents/MATLAB/levmar-2.6/levvy> levmar.c -llevmar -lclapack -lblas -lf2c
Where the path with option L, is just the path to all of the files included in the 'levmar' library supplied by the author.
My OS is mac OS 10.12.1 and MATLAB version is MATLAB_R2016b.
I've also tried this on a system operating on OS X 10.11.6 and MATLAB_R2015b, but get the equivalent error.
Any help would be much appreciated.
Thanks a lot.

Best Answer

/Applications/MATLAB_R2016b.app/bin/maci64 should be a directory not a file.
A complaint about -L/Applications/MATLAB_R2016b.app/bin/maci64 not existing might mean that it has parsed that entire string as if it is a file name to compile instead of as being an option indicating where to find libraries.
mex -DHAVE_LAPACK -I.. -O -L</Users/martinmackinnon/Documents/MATLAB/levmar-2.6/levvy> levmar.c -llevmar -lclapack -lblas -lf2c
The < and > should not be part of the command.
Related Question