libSvm是一个很好用的svm工具。在安装过程中遇到了一个问题:
C:\PROGRA~1\MATLAB\R2012B\BIN\MEX.PL: Error: 'libsvmread.c' not found.
If make.m fails, please check README about detailed instructions.
为什么呢?网上查了很多资料,众说纷纭,有的说是路径问题,有的说是版本问题。到底是什么问题?
我实验了很多版本,都是不行的。。。
最终使用的是3.14版本,结果成功了!
失败原因:当前路径问题。亲啊,就是当前路径问题!
请你按照我的步骤一步一步往下进行,保证亲测成功!
1. 下载libsvm3.14版本,将其解压到matlab的 安装目录-toolbox下。比如我的是:
C:\Program Files\MATLAB\R2012b\toolbox\libsvm-3.14
2. 添加搜索路径
HOME-Set Path-Add Folder-libsvm中matlab所在路径。比如我的是:
C:\Program Files\MATLAB\R2012b\toolbox\libsvm-3.14\matlab
记住要选择libsvm-3.14下的matlab哦,亲~其他的不行
3. 打开matlab。libsvm使用的是c++,而matlab没有c++编译器,所以需要选择外装的c++编译器。我用的是VS2010。VC6.0以上版本网友也亲测可用,但是我没试过。方法如下:
>> 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/R2012b/win32.html
Please choose your compiler for building MEX-files:
Would you like mex to locate installed compilers [y]/n? y
Select a compiler:
[1] Lcc-win32 C 2.4.1 in C:\PROGRA~1\MATLAB\R2012b\sys\lcc
[2] Microsoft Visual C++ 2010 in g:\ProgramFiles\Microsoft Visual Studio 10.0
[0] None
Compiler: 2
Please verify your choices:
Compiler: Microsoft Visual C++ 2010
Location: g:\ProgramFiles\Microsoft Visual Studio 10.0
Are these correct [y]/n? y
***************************************************************************
Warning: MEX-files generated using Microsoft Visual C++ 2010 require
that Microsoft Visual Studio 2010 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:\Documents and Settings\administer1\Application Data\MathWorks\MATLAB\R2012b\mexopts.bat
From template: C:\PROGRA~1\MATLAB\R2012b\bin\win32\mexopts\msvc100opts.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/techdoc/matlab_external/bsflnue-1.html
Building with the -largeArrayDims option enables the new API.
**************************************************************************
>>
出现上述情况证明选择编译器成功。其中红色字体是需要填写的,黑色字体是matlab自动给出的。选择编译器过程中(即我输入红色“2”的地方),会根据你电脑中编译器的不同而不同。应当选择较高版本的编译器。如果没有安装visual studio,则建议安装一个高于6.0的版本。
4. >> make
在这里很多同志们会出现各种问题。我的是:
>> make
C:\PROGRA~1\MATLAB\R2012B\BIN\MEX.PL: Error: 'libsvmread.c' not found.
If make.m fails, please check README about detailed instructions.
试了很多方法都不行,包括换版本。其实我告诉你,就是当前路径的问题!
解决方法:
看这里:
红框里的是当前路径,而不是保存的libsvm中matlab的路径!
更改此路径,比如我的改为:
然后再make:
>> make
>>
OK,成功!
记得改当前路径!
原文:http://write.blog.csdn.net/postedit