Using the MX Matrix Library in General C Code

Hello. I'm trying to create a MEX filte. In order to debug the code I'm trying to compile it in Visual Studio.
I'm replacing the header with 'void main'. For some reason something is going wrong with using 'mex.h'.
How could I use the MX library in a general C / C++ code?
Thank You.

5 comentarios

Kaustubha Govind
Kaustubha Govind el 5 de Jul. de 2012
It's not clear what you mean by "something is going wrong". Please specify error messages if any, or the observed behavior.
Royi Avital
Royi Avital el 6 de Jul. de 2012
I mean going wrong is that the code won't compile. Yet when I compile it from MATLAB using the MEX command it will work.
My question is simple. Let's say I want to create a 'C' code and use the function Mathworks provides to MEX yet compile it into an EXE code, can I do that? How should I do that?
Thanks.
TAB
TAB el 6 de Jul. de 2012
In which format you want to compile your code ? mex or exe ?
Royi Avital
Royi Avital el 7 de Jul. de 2012
Maybe I need to clarify it. I want to write a regular C code (main function, compiled into EXE). I want to use the MX library just as I can use the stdio library.
Could that be done? How can I do that?
It seems that adding the 'h' file (mex.h) won't do.
Royi Avital
Royi Avital el 22 de Abr. de 2020
@Kaustubha Govind, Let me ask you that, is there a way to create a standalone compiled file (From a C file) which uses MATLAB C Matrix API?

Iniciar sesión para comentar.

 Respuesta aceptada

Royi Avital
Royi Avital el 13 de Sept. de 2014

0 votos

It seems Mathworks did something to disable the option to create a C code which uses their library outside the MEX scope.
I Don't get how they do it, but that's the result.

Más respuestas (1)

Walter Roberson
Walter Roberson el 7 de Jul. de 2012

0 votos

"void main" need not be accepted as the signature of the main routine of a C program. main() is defined to return an integer in C, so telling C that your "main" routine has a void return is going to generate something does not have the proper datatypes for the required main program.

1 comentario

Royi Avital
Royi Avital el 7 de Jul. de 2012
So I will write an 'int main'. Still, How can I use the MX library?

Iniciar sesión para comentar.

Categorías

Más información sobre Write C Functions Callable from MATLAB (MEX Files) en Centro de ayuda y File Exchange.

Productos

Etiquetas

Preguntada:

el 5 de Jul. de 2012

Comentada:

el 22 de Abr. de 2020

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by