matlabgcclibsvmmingw-w64

Compiling LIBSVM for Matlab R2016a


I want to use LiBSVM with Matlab R2016a under Windows 7 64 Bit with the MinGW64 compiler and the precompiled mex files didn't work for me. When I tried to run the standard make file that comes with LibSVM the following error occurs: *Building with 'MinGW64 Compiler (C)'. Error using mex gcc: error: -fexceptions: No such file or directory * The makefile looks like this:

mex CFLAGS="\$CFLAGS -std=c99" -largeArrayDims libsvmread.c
mex CFLAGS="\$CFLAGS -std=c99" -largeArrayDims libsvmwrite.c
mex CFLAGS="\$CFLAGS -std=c99" -I.. -largeArrayDims svmtrain.c ../svm.cpp svm_model_matlab.c
mex CFLAGS="\$CFLAGS -std=c99" -I.. -largeArrayDims svmpredict.c ../svm.cpp svm_model_matlab.c

In another answer to a stackoverflow question I saw that somebody used this code for compiling:

mex -O -largeArrayDims libsvmread.c
mex -O -largeArrayDims libsvmwrite.c
mex -O -I.. -largeArrayDims svmtrain.c ../svm.cpp svm_model_matlab.c
mex -O -I.. -largeArrayDims svmpredict.c ../svm.cpp svm_model_matlab.c

This also works for me. What is the difference between the two ways of compiling LibSVM and are there any disadvantages of using the second option?

edit: this is the so question I mentioned: http://ch.mathworks.com/matlabcentral/newsreader/view_thread/297195 after doing a bit more research I understood that -std=c99 selects a c language version which is not fully implemented for gcc under windows and -O optimizes the object code. In http://www.csie.ntu.edu.tw/~cjlin/libsvm/faq.html#f213 the developers mention that they actually did not use any c99 languge features. So compiling the library should have no disadvantages, right?


Solution

  • The "error: -fexceptions: No such file or directory." May also be solved by changing CFLAGS to COMPFLAGS.

    Credit https://github.com/cjlin1/libsvm/issues/55