Reputation: 3283
I want to use libsvm on Octave (on a Windows platform). If I understand well from the readme file, and from a dozens of posts of the internet, I don't have to make or compile anything, only copy the mexw32 and mexw64 files to my Octave working directory. If I do this, nothing happens, the error is the same as before when I want to run my sample code:
error: `libsvmread' undefined near line 7 column 11
I've tried to run make from the Octave command prompt too, but then I got other errors:
warning: unable to find mkoctfile in expected location: `c:\Program Files (x86)\
Octave-3.6.2\bin\mkoctfile-3.6.2'
warning: mkoctfile exited with failure status
But there is a mkoctfile-3.6.2.exe at the given directory...
I have already tried to edit the octaverc
file too...but it didn't help.
Any ideas how to install libsvm correctly?
Upvotes: 2
Views: 4584
Reputation: 24218
According to the README file in the matlab
subfolder of the LIBSVM distribution (I looked at 3.13), the included binaries are only for the 64-bit version of Matlab on Windows. These binaries definitely did not work with my version of Octave on Windows! To get LIBSVM to work with Octave, we will have to build Octave-specific .mex files and put them somewhere Octave can find them.
I put together a walkthrough of the process at http://flyingpies.wordpress.com/2012/11/20/getting-libsvm-to-work-with-octave-on-windows/. In a nutshell, the steps are:
Make sure you have the Windows version of Octave built with Visual Studio (i.e. not the cygwin or mingw one.) I'm certain comparable steps can be taken with these other versions, by I didn't try them out.
Get a copy of Visual Studio 2010 or 2012. Either worked fine for me. You just need the command line C compiler and linker out of that big package. The express version of VS is available for free from Microsoft, though I didn't try that out.
In a command prompt window, run the vcvarsall.bat
batch file from the Visual C folder of Visual Studio, to prime your environment for compilation.
Add the Octave bin folder to your path (C:\Program Files (x86)\Octave-3.6.2\bin
on my machine). This addresses the 'cannot find mkoctfile' problem you encountered.
Edit Octave's math.h include file to reference the correct location of Visual Studio's math.h. I had to change line 74 of c:\Program Files (x86)\Octave-3.6.2\include\math.h
from c:/Program Files/Microsoft Visual Studio 10.0/VC/include/math.h
to c:/Program Files (x86)/Microsoft Visual Studio 11.0/VC/include/math.h
.
In the same command prompt window primed with vcvarsall and the path, start Octave, navigate to the matlab subfolder of the LIBSVM distribution, and run the make command. This executes the make.m file in that folder, which will build the .mex files.
Copy the .mex files to a folder where Octave can find them. I put them in C:\Program Files (x86)\Octave-3.6.2\lib\octave\3.6.2\site\oct\i686-pc-mingw32
.
At this point, if you start Octave, LIBSVM interface commands should be available. For example, the svmtrain
command should run.
Upvotes: 2