Warning
This page is located in archive. Go to the latest version of this course pages.

How to Compile MATLAB Mex Files

general guidelines

In MATLAB:

cd stprtoolbox_path
stprpath
compilemex
% when compilemex complains about missing compiler run mex -setup and then compilemex again

If you are not successful, do not hesitate to contact us in the student forum. Please post output of the MATLAB ver command.

OS X

  1. Install Command line tools in XCode Preferences → Downloads → Command line tools
  2. Comment out lines 144-145 in stprtool/compilemex.m
    elseif strncmp(cname,'MAC',3)
    %   p = strrep(p,':',':;');
    %   p = strrep(p,'/',':');
  3. In MATLAB
    cd stprtool_path/
    compilemex('../stprtool')

Command output should look like:

Compiling MEX files of STPRtool...
mex -O -I../stprtool/kernels -outdir ../stprtool/kernels ../stprtool/kernels/kernel.c ../stprtool/kernels/kernel_fun.c 
/Applications/MATLAB_R2012a.app/bin/mex: line 1022: [: /Volumes/Mac: binary operator expected
mex -O -I../stprtool/kernels -outdir ../stprtool/kernels ../stprtool/kernels/diagker.c ../stprtool/kernels/kernel_fun.c 
/Applications/MATLAB_R2012a.app/bin/mex: line 1022: [: /Volumes/Mac: binary operator expected
mex -O -I../stprtool/kernels -outdir ../stprtool/svm ../stprtool/svm/smo1d_mex.c 
/Applications/MATLAB_R2012a.app/bin/mex: line 1022: [: /Volumes/Mac: binary operator expected
mex -O -I../stprtool/kernels -outdir ../stprtool/svm ../stprtool/svm/smo_mex.c ../stprtool/kernels/kernel_fun.c 
/Applications/MATLAB_R2012a.app/bin/mex: line 1022: [: /Volumes/Mac: binary operator expected
mex -O -I../stprtool/kernels -outdir ../stprtool/svm ../stprtool/svm/bsvm2_mex.c ../stprtool/kernels/kernel_fun.c ../stprtool/optimization/gmnplib.c 
/Applications/MATLAB_R2012a.app/bin/mex: line 1022: [: /Volumes/Mac: binary operator expected
mex -O -I../stprtool/ -outdir ../stprtool/misc ../stprtool/misc/knnclass_mex.c 
/Applications/MATLAB_R2012a.app/bin/mex: line 1022: [: /Volumes/Mac: binary operator expected
mex -O -I../stprtool/kernels -outdir ../stprtool/svm ../stprtool/svm/svm2_mex.c ../stprtool/kernels/kernel_fun.c ../stprtool/optimization/gnpplib.c 
/Applications/MATLAB_R2012a.app/bin/mex: line 1022: [: /Volumes/Mac: binary operator expected
mex -O -I../stprtool/kernels -outdir ../stprtool/kernels ../stprtool/kernels/kernelproj_mex.c ../stprtool/kernels/kernel_fun.c 
/Applications/MATLAB_R2012a.app/bin/mex: line 1022: [: /Volumes/Mac: binary operator expected
mex -O -I../stprtool/ -outdir ../stprtool/optimization ../stprtool/optimization/gmnp_mex.c ../stprtool/optimization/gmnplib.c 
/Applications/MATLAB_R2012a.app/bin/mex: line 1022: [: /Volumes/Mac: binary operator expected
mex -O -I../stprtool/ -outdir ../stprtool/optimization ../stprtool/optimization/gnnls_mex.c ../stprtool/optimization/gnnlslib.c 
/Applications/MATLAB_R2012a.app/bin/mex: line 1022: [: /Volumes/Mac: binary operator expected
mex -O -I../stprtool/ -outdir ../stprtool/optimization ../stprtool/optimization/gnpp_mex.c ../stprtool/optimization/gnpplib.c 
/Applications/MATLAB_R2012a.app/bin/mex: line 1022: [: /Volumes/Mac: binary operator expected
mex -O -I../stprtool/ -outdir ../stprtool/optimization ../stprtool/optimization/qpssvm_mex.c ../stprtool/optimization/qpssvmlib.c 
/Applications/MATLAB_R2012a.app/bin/mex: line 1022: [: /Volumes/Mac: binary operator expected
mex -O -I../stprtool/ -outdir ../stprtool/optimization ../stprtool/optimization/qpbsvm_mex.c ../stprtool/optimization/qpbsvmlib.c 
/Applications/MATLAB_R2012a.app/bin/mex: line 1022: [: /Volumes/Mac: binary operator expected
mex -O -I../stprtool/ -outdir ../stprtool/optimization ../stprtool/optimization/gsmo_mex.c ../stprtool/optimization/gsmolib.c 
/Applications/MATLAB_R2012a.app/bin/mex: line 1022: [: /Volumes/Mac: binary operator expected
MEX-files compiled successfully.

Thanks to Martin Pekař for OS X howto.

courses/be5b33rpz/labs/08_svm/matlab_mex_compilation.txt · Last modified: 2018/09/13 10:56 (external edit)