I wanted to explore toying with the libsvm Support Vector Machine library via Matlab in Windows x64. I ran into several road blocks and figured I would share with the rest of our viewers at home how I overcame them.
First, in order to interface with C/C++ code in Matlab, I had to get MEX working. Mathworks will instruct you to run “mex -setup” at the command line and have you select your installed compiler. For me, this happened to be Visual Studio 2008 Professional SP1. Unfortunately, by default the “X64 Compilers and Tools” are not installed unless you manually check the check box when initially installing Visual Studio (see footnote 3 here). After installing Visual Studio, and then “X64 Compilers and Tools” (if you are running Windows x64) you can then finally run mex -setup in Matlab, and you should be good to go with mex. You can test your mex configuration to see if it’s working by typing “mex yprime.c”.
I then downloaded libsvm’s Matlab interface. I unzipped it, set up my work directory and typed “make” at the Matlab command line. After doing this and trying to execute the svmtrain function, I received an error about “-largeArrayDims” associated with a x64 bit architecture. After reading through the FAQ on the libsvm page as well as the readme that came with the download, I uncovered you have to add “-largeArrayDims” to the make.m file. I edited my make.m file (additions bolded) as follows for my x64 bit architecture:
mex -largeArrayDims -O -c svm.cpp
mex -largeArrayDims -O -c svm_model_matlab.c
mex -largeArrayDims -O svmtrain.c svm.obj svm_model_matlab.obj
mex -largeArrayDims -O svmpredict.c svm.obj svm_model_matlab.obj
mex -largeArrayDims -O libsvmread.c
mex -largeArrayDims -O libsvmwrite.c
After editing the make.m file, I typed make from the command line and then the library started working! I’m looking forward to using the libsvm library!
Hsu et. al. wrote <this technical report> as a practical guide documenting parameter selection and scaling input values for the libsvm package.
Chang et. al. wrote <this publication> about some theoretical aspects of SVM and implementation details for the libsvm library.