Convert MATLAB code to C++ code
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have a simple function in M-function file which I want to convert to C++.
After following all the steps mentioned in the Documentation, I got the .cpp file ... However when I run this file in Visual studio, I got the following error: "error LNK1561: entry point must be defined" since the code doesn't have int main() at the beginning.
This is the generated c++ code:
/* * emcrand.cpp * * Embedded MATLAB Coder code generation for function 'emcrand' * * C source code generated on: Sat Apr 14 17:24:57 2012 * */
/* Include files */ #include "rt_nonfinite.h" #include "emcrand.h" #include "rand.h"
/* Type Definitions */
/* Named Constants */
/* Variable Declarations */
/* Variable Definitions */
/* Function Declarations */
/* Function Definitions */ real_T emcrand(void) { return m_rand(); }
/* End of Embedded MATLAB Coder code generation (emcrand.cpp) */
Would you please help finding what and where possibly could be the error ? Why the .cpp file doesn't have the int main() as it should be ?
Thanks.
0 comentarios
Respuesta aceptada
Rick Rosson
el 14 de Abr. de 2012
MATLAB Coder does not generate a main() function for you. You have to write this function yourself in C or C++ and include it in the parent project before compiling the generated code.
Más respuestas (0)
Ver también
Categorías
Más información sobre Deploy to C++ Applications Using MATLAB Data API (C++11) en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!