From: Peter on
Hey,

i have a little problem. After compilation of a c File with mex, the execution does not work and i don't know why.


MATLAB OUTPUT
--------------------------------------------------------
EDU>> mex helloworld.c
helloworld.c:12:2: warning: no newline at end of file
EDU>> helloworld
Mex file entry point is missing. Please check the (case-sensitive)
spelling of mexFunction (for C MEX-files), or the (case-insensitive)
spelling of MEXFUNCTION (for FORTRAN MEX-files).
??? Invalid MEX-file
'/home/peter/work/aki_data/data/helloworld.mexglx': .
---------------------------------------------------------

This would not work with the following c Code.

C-CODE
-----------------------------------------------------------

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "matrix.h"
#include "mex.h"

void helloworld(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
printf("Hello World!\n");
}
------------------------------------------------------------

Does anybody know this problem?

Peter
From: Rune Allnor on
On 10 Jul, 11:21, "Peter " <Peter...(a)googlemail.com> wrote:

> #include <stdio.h>
> #include <stdlib.h>
> #include <math.h>
> #include "matrix.h"
> #include "mex.h"  
>
> void helloworld(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
> {
>   printf("Hello World!\n");}
>
>  ------------------------------------------------------------
>
> Does anybody know this problem?

This is the as omnipresent as infamous SUS - "Stupid User
Syndrome" - where somebdoy starts hacking away without having
a clue what he is doing.

The cure is simple, although you might not like to hear that *you*
are the only one that can correct it: *You* need to check the
documentation. There are several example files shipped with matlab
that demonstrate how to do things.

Rune
From: Bruno Luong on
"Peter " <Peterhae(a)googlemail.com> wrote in message <i19e21$1qm$1(a)fred.mathworks.com>...
> Hey,
>
> i have a little problem. After compilation of a c File with mex, the execution does not work and i don't know why.
>
>
> MATLAB OUTPUT
> --------------------------------------------------------
> EDU>> mex helloworld.c
> helloworld.c:12:2: warning: no newline at end of file
> EDU>> helloworld
> Mex file entry point is missing. Please check the (case-sensitive)
> spelling of mexFunction (for C MEX-files), or the (case-insensitive)
> spelling of MEXFUNCTION (for FORTRAN MEX-files).
> ??? Invalid MEX-file
> '/home/peter/work/aki_data/data/helloworld.mexglx': .
> ---------------------------------------------------------
>
> This would not work with the following c Code.
>
> C-CODE
> -----------------------------------------------------------
>
> #include <stdio.h>
> #include <stdlib.h>
> #include <math.h>
> #include "matrix.h"
> #include "mex.h"
>
> void helloworld(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
> {
> printf("Hello World!\n");
> }
> ------------------------------------------------------------
>
> Does anybody know this problem?
>
> Peter

The GATEWAY function MUST be named "mexFunction", you can't rename it to helloworld.

void mexFunction(int nlhs, mxArray *plhs[],int nrhs, const mxArray *prhs[])
{
...
}

Also it is recommended to use mexPrintf rather than printf

Bruno
From: Peter on
Some other call that more

apathic....

arrogant people are thinking how intelligent child like you they are when they find those great acronyms...

Otherwise a simple hint would be much more nice but if it gives you a little kick then it is ok too.

Greets Peter
From: Rune Allnor on
On 10 Jul, 12:49, "Peter " <Peter...(a)googlemail.com> wrote:
> Some other call that more
>
> apathic....
>
> arrogant people are thinking how intelligent child like you they are when they find those great acronyms...
>
> Otherwise a simple hint would be  much more nice but if it gives you a little kick then it is ok too.
>
> Greets Peter

Ok, since you ask so nicely: RTFM!

Not *my* acronym, and well deserved on your part.

Rune