Download and extract libsvm in a directory of your choosing, say C:\libsvm

As described in the C:\libsvm\matlab\README file, first you have to make sure a supported C/C++ compiler is installed. Note that on 64-bit systems, you need the correct 64-bit version of the compiler (e.g. Windows SDK is needed for Visual Studio Express edition)

>> mex -setup

Once you have selected a compiler, you need to compile the MEX-files:

>> cd('C:\libsvm\matlab')
>> make

Finally add the folder with the generated binaries to the MATLAB search path:

>> addpath('C:\libsvm\matlab')

Test the library with a simple example (fake data):

>> labels = double(rand(10,1)>0.5);
>> data = rand(10,5);
>> model = svmtrain(labels, data, '-s 0 -t 2 -c 1 -g 0.1')

Note that the current version of libsvm includes pre-compiled 64-bit MEX-files for Windows. The binaries are located in C:\libsvm\windows\*.mexw64 (copy those to the matlab subfolder from above)

Answer from Amro on Stack Overflow
Top answer
1 of 2
30

Download and extract libsvm in a directory of your choosing, say C:\libsvm

As described in the C:\libsvm\matlab\README file, first you have to make sure a supported C/C++ compiler is installed. Note that on 64-bit systems, you need the correct 64-bit version of the compiler (e.g. Windows SDK is needed for Visual Studio Express edition)

>> mex -setup

Once you have selected a compiler, you need to compile the MEX-files:

>> cd('C:\libsvm\matlab')
>> make

Finally add the folder with the generated binaries to the MATLAB search path:

>> addpath('C:\libsvm\matlab')

Test the library with a simple example (fake data):

>> labels = double(rand(10,1)>0.5);
>> data = rand(10,5);
>> model = svmtrain(labels, data, '-s 0 -t 2 -c 1 -g 0.1')

Note that the current version of libsvm includes pre-compiled 64-bit MEX-files for Windows. The binaries are located in C:\libsvm\windows\*.mexw64 (copy those to the matlab subfolder from above)

2 of 2
2

For me I didn't need to recompile the libsvm files(it did cause some problems with the .net framwork and windows SDK) I only used the already compiled files and added them to a new folder by following the steps mentioned here minus the make step.

So to summarize:

1- I think you need to create "libsvm" folder under "C:\Program Files\MATLAB\R2014b\toolbox\".

2- Then copy the *.mexw64 files from the "libsvm-3.21\windows" folder to the new folder.

3- finally add the libsvm folder you just created to matlab bath by clicking the set path button in home and adding the new folder with the path "C:\Program Files\MATLAB\R2014b\toolbox\libsvm"

🌐
MathWorks
mathworks.com › matlabcentral › answers › 144542-how-to-run-libsvm-on-matlab
How to run libsvm on matlab? - MATLAB Answers - MATLAB Central
August 3, 2014 - Sign in to answer this question. ... Add the svmtrain, svmpredict, libsvmwrite & libscmread .mex Files to your matlab path (probably you just put them in the working folder...)
Top answer
1 of 3
8

For the time being, it does not matter where you put that folder. You'll have to compile the Matlab-MEX files, from the source code that resides in the matlab subfolder of your extracted libsvm package.

Below, I will call the libsvm-3.14 (for example: C:\libsvm-3.14) extracted folder ROOT (so replace ROOT wilth C:\libsvm-3.14 below).

So, fire up Matlab and, then, at its command prompt, type:

cd ROOT
cd matlab
make

Now, in the ROOT/matlab folder, you should have obtained two MEX files (with the .mexw32 or .mexw64 extension). These are the files that you will use from now on. You can discard the rest, except those files (and, maybe, some other generated libraries).

According to the Makefile (that is ROOT/matlab/make.m), the MEX files are called svmtrain and svmpredic (+ the extension).

So, next step would be to create a subfolder called libsvm/ under your's Matlab/toolbox folder, copy the two MEX files therein and, then, add that libsvm/ folder to the Matlab Path (not the Path of your system, but of your Matlab installation).

Then, by typing:

svmtrain

and

svmpredict

you should have the help (usage) of these two functions.

2 of 3
4

With the aid of @axeoth, here is the solution. I followed instruction files in matlab subfolder of extracted libsvm package. I downloaded and installed Microsoft Visual Studio 2010 and wrote 'mex -setup' on command window of MATLAB to choose a suitable compiler for mex (I use MATLAB R2012b in 32-bit PC, so I found supported compilers in this link http://www.mathworks.com/support/compilers/R2012b/win64.html) After then, I followed @axeoth's instructions. I changed the name of the folder to ROOT and moved it to Documents/MATLAB. I started MATLAB and on command window, I wrote these below "one by one"

>> cd C:\Users\HUstat\Documents\MATLAB\ROOT\matlab
>> cd matlab
>> make

then I copied everything obtained in ROOT/matlab subfolder. I created a new folder named libsvm under MATLAB/toolbox folder and pasted everything there. and then, I added that libsvm/ folder to the Matlab Path by using "Set Path" button on MATLAB R2012b. After then I wrote "svmtrain" and "svmpredict" so I got the helps of these two commands.

🌐
MathWorks
mathworks.com › matlabcentral › answers › 47595-how-we-can-use-libsvm-in-matlab
How we can use libsvm in MATLAB - MATLAB Answers - MATLAB Central
September 7, 2012 - How we can use libsvm in MATLAB. Learn more about support vector machine, data classification, svm, libsvm
🌐
Google Sites
sites.google.com › site › kittipat › libsvm_matlab
Kittipat's Homepage - libsvm for MATLAB
Just read the readme file in the package. It's very easy. You can do it in both terminal and in MATLAB workspace. On Ubuntu machine, just to make sure you have gcc in your machine.
🌐
MathWorks
mathworks.com › matlabcentral › answers › 317747-how-install-libsvm-please
how install libsvm please - MATLAB Answers - MATLAB Central
December 21, 2016 - You will see updates in your followed content feed. You may receive emails, depending on your communication preferences. ... I need to install libsvm to classify my database into classes.
🌐
MathWorks
mathworks.com › matlabcentral › answers › 247863-how-to-install-libsvm-in-matlab
How to install LIBSVM in Matlab -
October 10, 2015 - I have followed the instructions to LIBSVM in Matlab. However, at the final, when I typed" make" and pressed enter, it shown an error message "C:\MATLAB7\BIN\WIN32\MEX.PL: Error: 'CFLAGS=\$CFLAGS -std=c99' not found. If make.m fails, please check README about detailed instructions" Does anyone know why it happened and how to solve it? Thank you ... https://www.mathworks.com/matlabcentral/answers/247863-how-to-install-libsvm-in-matlab#comment_315294
Find elsewhere
🌐
SciVision
scivision.dev › matlab-octave-python-libsvm-install
Install LibSVM in Matlab, GNU Octave and Python | Scientific Computing
February 14, 2022 - LibSVM is a popular machine learning toolbox for Support Vector Machines SVM. Here's an easy way to install LibSVM in Matlab, GNU Octave and Python.
🌐
Vivian Website
csie.ntu.edu.tw › ~cjlin › libsvm › oldfiles › index-1.0.html
Download LIBSVM
In addition, we provide a graphic interface to demonstrate 2-D pattern recognition. The current release (Version 1.04) of LIBSVM can be obtained by downloading the zip file. (Due to possible slow connection, you may want to download it from other places: US Download.
🌐
Quora
quora.com › How-do-I-run-LIBSVM-in-MATLAB
How to run LIBSVM in MATLAB - Quora
Answer: You can download the LIBSVM on it's homepage. LIBSVM -- A Library for Support Vector Machines The library was written in C. So you will have to use mex to compile it. You can check it in the README file.
🌐
Alibaba Cloud
topic.alibabacloud.com › a › how-to-install-libsvm-package-in-matlab_8_8_31120255.html
How to install LIBSVM package in MATLAB
November 6, 2016 - Open matlab and add Libsvm-3.21\matlab to the path, such as adding: \matlab\r2014a\toolbox\libsvm-3.21\matlab to the path. ... If the prompt does not have a C + + compiler, then download Winsdk_web.exe according to the prompt URL, and then double-click Run Winsdk_web.exe, install to the end ...
🌐
MathWorks
mathworks.com › matlabcentral › answers › 68367-how-install-libsvm-in-matlab
how install libsvm in matlab ? - MATLAB Answers - MATLAB Central
March 23, 2013 - https://www.mathworks.com/matlabcentral/answers/68367-how-install-libsvm-in-matlab#comment_138441 · Cancel Copy to Clipboard · ⋮ · Link · × · https://www.mathworks.com/matlabcentral/answers/68367-how-install-libsvm-in-matlab#comment_138441 · Cancel Copy to Clipboard ·
🌐
Wordpress
iqbalnaved.wordpress.com › 2015 › 04 › 18 › adding-libsvm-3-2-to-matlab-r2013a
Adding libSVM 3.2 to MATLAB R2013a – The Learning Machines
April 18, 2015 - 1. Download libsvm 3.2 2. Check ... (I installed MS Visual Studio 2008 SP1 and it worked fine.) 4. go to libsvm-3.20/matlab directory and run the 'make' command....
🌐
Stack Overflow
stackoverflow.com › questions › 35299343 › install-libsvm-for-matlab-r2014a-in-windows-8-1
installation - Install LibSVM for Matlab R2014a in Windows 8.1 - Stack Overflow
Download (and install) Microsoft Windows SDK 7.1, close and reopen Matlab and then run mex -setup to check that Matlab detects your compiler.
🌐
GitHub
github.com › cjlin1 › libsvm › blob › master › matlab › README
libsvm/matlab/README at master · cjlin1/libsvm
to build 'libsvmread.mex', 'libsvmwrite.mex', 'svmtrain.mex', and ... MATLAB will choose the default compiler. If you have multiple compliers, a list is given and you can choose one from the list. For more details, ... On Windows, make.m has been tested via using Visual C++. ... Makefile and type 'make' in a command window. Note that we assume · your MATLAB is installed in '/usr/local/matlab'.
Author   cjlin1
🌐
Carnegie Mellon University
cs.cmu.edu › ~guestrin › Class › 10701 › hws › hw3 › libsvm_inst.txt
libsvm_inst.txt
Otherwise your machine should have g++ and make installed on it. To see if you have g++, try $ g++ --version in a terminal. - 32-bit Windows Simply copy files 'svmpredict.mexwin32' and 'svmtrain.mexw32' to your working directory in Matlab. - 64-bit Windows I'm not sure about these. Let me know if you're having problems. - Linux & Mac OS X with g++ and Make 1. Make sure 'MATLABDIR' in libsvm...
🌐
Vivian Website
csie.ntu.edu.tw › ~cjlin › libsvm
LIBSVM -- A Library for Support Vector Machines
Our goal is to help users from other fields to easily use SVM as a tool. LIBSVM provides a simple interface where users can easily link it with their own programs. Main features of LIBSVM include ... Python, R, MATLAB, Perl, Ruby, Weka, Common LISP, CLISP, Haskell, OCaml, LabVIEW, and PHP interfaces. C# .NET code and CUDA extension is available. It's also included in some data mining environments: RapidMiner, PCP, and LIONsolver. Some popular package managers (e.g., pip and vcpkg) can install LIBSVM easily.
🌐
Readout
readout.info › downloads › additional-code › libsvm
Neural Decoding Toolbox - LIBSVM
To use the precompiled LIBSVM code, download the zip the files by clicking the link below, upzip the files, and put the directory libsvm-3.11/ in the ndt.1.0.0/external_libraries/ directory. Run the add_ndt_paths_and_init_rand_generator helper function to add the code to Matlab’s path and ...