From: Sapna on
Hi,

I am trying to compile a c code in matlab. The functions name is qp.c which calls another function pr_logo.c. I've added libraries like stdafx.h and targetvar.h along with mex.h in the current directory, that being C:\...\Matlab\R2009b\extern\examples\mex. I've used mex -setup and mex qp.c pr_logo.c to compile the c code. It is giving the error

C:\PROGRA~1\MATLAB\R2009B\BIN\MEX.PL: Error: 'pr_logo.c' not found.

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

I am a little confused as to what to do about this. Does anyone know what I can do to fix this issue?

Thanks,
Sapna
From: Jan Simon on
Dear Sapna,

> mex qp.c pr_logo.c to compile the c code. It is giving the error
>
> C:\PROGRA~1\MATLAB\R2009B\BIN\MEX.PL: Error: 'pr_logo.c' not found.

This means, that the file pr_logo.c cannot be found in the path. Where is it? In the same folder as qp.c? Try:
which('pr_logo.c')

Jan
From: Sapna on
Hi Jan,

I have copied both qp.c and pr_logo.c in the current directory i.e.,

C:\PROGRA~1\MATLAB\R2009B\extern\examples\mex

How should I compile the code without it reporting an error? I used
1) mex -setup

and
2)mex qp.c pr_logo.c

Sapna
From: Jan Simon on
Dear Sapna,

> I have copied both qp.c and pr_logo.c in the current directory i.e.,
> C:\PROGRA~1\MATLAB\R2009B\extern\examples\mex

I'd recommend not to use folders in Matlab's program directory. It is even no good idea to have write permissions for these folders (exception: "<matabroot>\toolbox\local", but even this can/should/might be secured).

> How should I compile the code without it reporting an error? I used
> 1) mex -setup
> 2) mex qp.c pr_logo.c

I do not expect that your problem is caused by the writing permissions of the folder. Anyway, you could copy both C-files to a location in your user path or to TEMP and try the compilation again. If really both files are found in the current directory, the error is strange. Perhaps you could add the folder to your Matlab path ("addpath(cd, '-end')"?!

Good luck, Jan
From: Sapna on
Hi Jan,

I have managed to compile it without giving the previous error. But now the error that is popping up is this

Error qp.c: C:\PROGRA~1\MATLAB\R2009B\sys\lcc\include\math.h: 8 syntax error; found `extern' expecting `;'

This is happening now that I am trying to create a debug version of this dll by using

mex -g qp.c pr_logo.c

and this is when it is giving me this error. A function in matlab calls this qp.c and qp.c in turn calls pr_logo.c. pr_logo has a .h file called math.h that it is using. It is giving error in this line

extern double _HUGE ;

There is a semi-colon there already. I don't know why it is popping up an error.

There was an existing code on qp.c and pr_logo.c which i modified slightly and now trying to compile it. Is this possible? I initially wrote the code in qp.c but now transferred it to pr_logo.c to check if it was still giving the error. Do you know what could be wrong?

Thanks,
"Jan Simon" <matlab.THIS_YEAR(a)nMINUSsimon.de> wrote in message <i1ne60$hn8$1(a)fred.mathworks.com>...
> Dear Sapna,
>
> > I have copied both qp.c and pr_logo.c in the current directory i.e.,
> > C:\PROGRA~1\MATLAB\R2009B\extern\examples\mex
>
> I'd recommend not to use folders in Matlab's program directory. It is even no good idea to have write permissions for these folders (exception: "<matabroot>\toolbox\local", but even this can/should/might be secured).
>
> > How should I compile the code without it reporting an error? I used
> > 1) mex -setup
> > 2) mex qp.c pr_logo.c
>
> I do not expect that your problem is caused by the writing permissions of the folder. Anyway, you could copy both C-files to a location in your user path or to TEMP and try the compilation again. If really both files are found in the current directory, the error is strange. Perhaps you could add the folder to your Matlab path ("addpath(cd, '-end')"?!
>
> Good luck, Jan