Reputation: 31
the adds-on explorer doesn't work as it needs a renewal license ... Is there anyway I can install the compiler to use a "mex -setup" command ?
Upvotes: 0
Views: 4905
Reputation: 11
The instructions below will work on Windows 7 64 bit machine, for Matlab R2016Aa:
System Requirements
In order to be able to use LIBSVM package you need to have a C compiler installed on your system.
How to install MinGW-w64 Compiler
-In Matlab go to ENVIRONMENT section under the HOME tab -Click on Add-Ons > Get Add-Ons -Select Features from left pane under Filter by Type -Click MinGW-w64 tdm-gcc -Click install -Support Package Installer window will pop up ---Get the URL - MinGW-w64 Runtime http://sourceforge.net/projects/tdm-gcc/files/Sources/TDM%20Sources/ --Download the executable --Make sure there is no space in the folder where you will download the compiler --Once the installation is completed, you should have a folder under C drive with a name TDM-GCC-64
-Set Environment Variables in Windows
-In Matlab
-Set the current folder to Documents>MATLAB>Libsvm-3.2.2>matlab folder -Test Compiler using yprime.c file -Type copyfile(fullfile(matlabroot,'extern','examples','mex','yprime.c'),'.','f')
-Set Environment in Matlab using the following command
YOU DO THIS EVERY TIME YOU START MATLAB AND WANT TO USE LIBSVM LIBRARY
setenv('MW_MINGW64_LOC','C:\TDM-GCC-64')
Type make
Type mex -setup (to choose suitable compiler for mex) You should get something like this:
MEX configured to use 'MinGW64 Compiler (C)' for C language
compilation. 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.
To choose a different language, select one from the following: mex -setup C++ mex -setup FORTRAN
-Type mex yprime.c You should get the following result: Building with 'MinGW64 Compiler (C)'. MEX completed successfully.
-Test the compiler
yprime(1,1:4) You should get the following ans =
2.0000 8.9685 4.0000 -1.0947 -Type make to build mex files for libvm read write and others. -You may get the following error initially:
make Building with 'MinGW64 Compiler (C)'. Error: C:\MATLAB\SupportPackages\R2016a\libsvm-3.22\matlab\make.m failed (line 13) gcc: error: -fexceptions: No such file or directory
-To resolve this issue, open make.m file and change CFLAGS= to COMPFLAGS, save it and call it again. -Successful installation will show the following
make Building with 'MinGW64 Compiler (C)'. MEX completed successfully. Building with 'MinGW64 Compiler (C)'. MEX completed successfully. Building with 'MinGW64 Compiler (C++)'. MEX completed successfully. Building with 'MinGW64 Compiler (C++)'. MEX completed successfully.
Upvotes: 1