网上关于matlab 上安装libsvm 的教程很多,但我在安装过程仍遇到了一些问题,本文既是为了自己在下次安装过程中提供参考,也为需要的童鞋们提供帮助。
本人在书写过程中参考了http://blog.csdn.net/loadstar_kun/article/details/7712308
首先本文针对的是操作系统是window 64bit,matlab2013a。
1. 下载最新版的libsvm工具箱
http://www.csie.ntu.edu.tw/~cjlin/libsvm/
window 系统应该选择下载zip file
2.安装编译环境
liabsvm在matlab中使用之前需要编译,而matlab 2013a 已经不再提供C、C++编译器,所以需要自行安装编译器,我安装的是visual studio 2012,之所以不选择很多人建议的VS 6.0,主要是在win64上安装起来太拙计了,还是用较新版的软件比较方便,当然VS 2012太大了,卸载也麻烦。编译器安装后就开始第三步吧。
3.编译
将下载的工具箱放在matlab的安装文件夹下C:\Program Files\MATLAB\R2013a\toolbox,此时开始添加路径
点击 Set Path,将libsvm-3.17文件夹及其 子文件夹都加载到搜索路径中(我之前安装不成功就是因为没有将libsvm-3.17文件夹及其 子文件夹都加载到搜索路径中),加载好后应该如下图所示一致。
路径添加好后,将当前路径切换到C:\Program Files\MATLAB\R2013a\toolbox\libsvm-3.17\matlab目录下就可以编译了。
>> mex -setup (自己键入)
Welcome to mex -setup. This utility will help you set up
a default compiler. For a list of supported compilers, see
http://www.mathworks.com/support/compilers/R2013a/win64.html
Please choose your compiler for building MEX-files:
Would you like mex to locate installed compilers [y]/n? y(选择y)
Select a compiler:
[1] Microsoft Visual C++ 2012 in D:\Program Files (x86)\Microsoft Visual Studio 11.0
[0] None
Compiler: 1
Please verify your choices:
Compiler: Microsoft Visual C++ 2012
Location: D:\Program Files (x86)\Microsoft Visual Studio 11.0
Are these correct [y]/n? y(选择y)
***************************************************************************
Warning: MEX-files generated using Microsoft Visual C++ 2012 require
that Microsoft Visual Studio 2012 run-time libraries be
available on the computer they are run on.
If you plan to redistribute your MEX-files to other MATLAB
users, be sure that they have the run-time libraries.
***************************************************************************
编译器配置完成后出现如下字样
Trying to update options file: C:\Users\yangmen\AppData\Roaming\MathWorks\MATLAB\R2013a\mexopts.bat
From template: C:\PROGRA~1\MATLAB\R2013a\bin\win64\mexopts\msvc110opts.bat
Done . . .
**************************************************************************
Warning: The MATLAB C and Fortran API has changed to support MATLAB
variables with more than 2^32-1 elements. In the near future
you will be required to update your code to utilize the new
API. You can find more information about this at:
http://www.mathworks.com/help/matlab/matlab_external/upgrading-mex-files-to-use-64-bit-api.html
Building with the -largeArrayDims option enables the new API.
**************************************************************************
最后键入make,稍等一会就可以啦。
>> make
OK啦。。。
4关于测试部分请参照 http://blog.csdn.net/loadstar_kun/article/details/7712308 ,如果在load数据过程中出现错误,请找一个老版本的heart_scale.mat 文件。