From: Thomas on
Hi,

I'm running matlab on a 64-bit linux machine and I'm having problems running mex to compile c++ programs. For example when I run mex on the example program yprime.c I get the following

mex yprime.c
/usr/bin/ld: cannot find -lmx
collect2: ld returned 1 exit status

mex: link of ' "yprime.mexa64"' failed.

I found out that I need to run

setenv('MATLAB_ARCH', 'glnx86')

in matlab first. I did this and now mex runs fine on this example. I now try to run mex on some software I download (libSVM) and when I run

make

I get the following error message

In file included from svm_model_matlab.c:3:
svm.h:51: error: expected specifier-qualifier-list before ‘/’ token
svm.h:53: error: stray ‘#’ in program
svm_model_matlab.c: In function ‘model_to_matlab_structure’:
svm_model_matlab.c:37: error: expected expression before ‘/’ token
svm_model_matlab.c:47: error: expected expression before ‘/’ token
svm_model_matlab.c:50: error: ‘struct svm_model’ has no member named ‘nr_class’
svm_model_matlab.c:53: error: expected expression before ‘/’ token
svm_model_matlab.c:56: error: ‘struct svm_model’ has no member named ‘l’
svm_model_matlab.c:59: error: expected expression before ‘/’ token
svm_model_matlab.c:64: error: ‘struct svm_model’ has no member named ‘rho’
svm_model_matlab.c:67: error: expected expression before ‘/’ token
svm_model_matlab.c:79: error: expected expression before ‘/’ token
svm_model_matlab.c:91: error: expected expression before ‘/’ token
svm_model_matlab.c:103: error: expected expression before ‘/’ token
svm_model_matlab.c:115: error: expected expression before ‘/’ token
svm_model_matlab.c:118: error: ‘struct svm_model’ has no member named ‘nr_class’
svm_model_matlab.c:119: error: ‘struct svm_model’ has no member named ‘l’
svm_model_matlab.c:120: error: ‘struct svm_model’ has no member named ‘l’
svm_model_matlab.c:120: error: ‘struct svm_model’ has no member named ‘sv_coef’
svm_model_matlab.c:123: error: expected expression before ‘/’ token
svm_model_matlab.c: In function ‘matlab_matrix_to_model’:
svm_model_matlab.c:217: error: ‘struct svm_model’ has no member named ‘rho’
svm_model_matlab.c:218: error: ‘struct svm_model’ has no member named ‘probA’
svm_model_matlab.c:219: error: ‘struct svm_model’ has no member named ‘probB’
svm_model_matlab.c:220: error: ‘struct svm_model’ has no member named ‘label’
svm_model_matlab.c:221: error: ‘struct svm_model’ has no member named ‘nSV’
svm_model_matlab.c:222: error: ‘struct svm_model’ has no member named ‘free_sv’
svm_model_matlab.c:222: error: expected expression before ‘/’ token
svm_model_matlab.c:233: error: ‘struct svm_model’ has no member named ‘nr_class’
svm_model_matlab.c:237: error: ‘struct svm_model’ has no member named ‘l’
svm_model_matlab.c:240: error: expected expression before ‘/’ token
svm_model_matlab.c:242: error: ‘struct svm_model’ has no member named ‘rho’
svm_model_matlab.c:245: error: ‘struct svm_model’ has no member named ‘rho’
svm_model_matlab.c:248: error: expected expression before ‘/’ token
svm_model_matlab.c:258: error: expected expression before ‘/’ token
svm_model_matlab.c:268: error: expected expression before ‘/’ token
svm_model_matlab.c:278: error: expected expression before ‘/’ token
svm_model_matlab.c:288: error: expected expression before ‘/’ token
svm_model_matlab.c:290: error: ‘struct svm_model’ has no member named ‘sv_coef’
svm_model_matlab.c:290: error: ‘struct svm_model’ has no member named ‘nr_class’
svm_model_matlab.c:291: error: ‘struct svm_model’ has no member named ‘nr_class’
svm_model_matlab.c:292: error: ‘struct svm_model’ has no member named ‘sv_coef’
svm_model_matlab.c:292: error: ‘struct svm_model’ has no member named ‘l’
svm_model_matlab.c:293: error: ‘struct svm_model’ has no member named ‘nr_class’
svm_model_matlab.c:294: error: ‘struct svm_model’ has no member named ‘l’
svm_model_matlab.c:295: error: ‘struct svm_model’ has no member named ‘sv_coef’
svm_model_matlab.c:295: error: ‘struct svm_model’ has no member named ‘l’
svm_model_matlab.c:298: error: expected expression before ‘/’ token

mex: compile of ' "svm_model_matlab.c"' failed.

??? Error using ==> mex at 218
Unable to complete successfully.

Error in ==> make at 8
mex -O -largeArrayDims -c svm_model_matlab.c

The code should be fine as it is widely ised by other people. What could be the problem?