Sunday, November 09, 2008

Making libsvm work in Mac OS X - Matlab R 2008

It was painful to get libsvm on matlab working in Mac OS X. First was a false error.

Matlab threw some weird error like this:
expr: syntax error
/p/matlab/bin/util/mex/mexutil.sh: line 13: [: too many arguments

and make did not work. SO I guessed that this was the error (which actually was not). On searching the net, I figured out that we should ignore this error and keep going.

The second was the issue with libsvm. The file make.m was referring .obj files while the makefile was generating .o files. So all .obj was to be search and replaced with .o. Things started working after that.

Hope this helps others who are struggling with libsvm and matlab in OS X.

3 comments:

Anonymous said...

have you solved this question?? I have met the same question with you....

Anonymous said...

Thanks! I ran into the same problem and your solution worked. I called "make" in the libsvm directory in Matlab, and got
this error:

*******************
EDU>> make
i686-apple-darwin10-gcc-4.0.1: svm.obj: No such file or directory
i686-apple-darwin10-gcc-4.0.1: svm_model_matlab.obj: No such file or directory

mex: link of ' "svmtrain.mexmaci"' failed.

??? Error using ==> mex at 213
Unable to complete successfully.

Error in ==> make at 7
mex -O svmtrain.c svm.obj svm_model_matlab.obj

*********************

and then I edited the make.m file in the libsvm directory and replaced the ".obj" with ".o" as you suggested in these two lines.

mex -O svmtrain.c svm.o svm_model_matlab.o

mex -O svmpredict.c svm.o svm_model_matlab.o

Anonymous said...

Yeah, as mentioned in the 2nd post, you have to change the .obj lines to .o
You also have to give the right path to the svm.cpp file if it has not been correctly provided. In my case I had to change line 5 to:
mex -O -largeArrayDims /Applications/libsvm-3.1/svm.cpp -c
In each of the c files that the make file invokes, you have to change the path of the files that are 'included'. For example, in svmtrain.c, there is a line that says #include "svm.h". I had to change it to:
#include "/Applications/libsvm-3.1/svm.h"
to make it work. Give the appropriate paths to all such files and it will work. Hope it helps!

Search this site

Google