How to auto generate wrapper for MatLab coder generated file?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
I am looking for help in using the MatLab generated DLL into my application directly. I have created a simple function in MatLab:
function [RetVal] = CalculateSum(SingleDimArray)
RetVal = sum(SingleDimArray);
end
Then I used a MatLab coder to generate a C/C++ DLL, which generates binary with following syntax:
double CalculateSum(const emxArray_real_T * SingleDimArray);
My application is having different requirement for using a DLL so I have created another DLL to wrap the DLL generated from MatLab coder like:
extern "C" __declspec(dllexport) void MyCalculateSum(VARIANT* Input, double* RetVal)
{
//Fetch Input array
SAFEARRAY *pInputArray = *(Input->pparray);
long arraySize = pInputArray->rgsabound[0].cElements;
double *pData = (double *) pInputArray->pvData;
//Create Input Args - Wrapper for MatLab generated code
emxArray_real_T *MLInputArray = emxCreateWrapper_real_T(pData, 1, MySize);
//Call MatLab functions
*RetVal = CalculateSum(MLInputArray);
//Release the struct
emxFree_real_T(&MLInputArray);
}
Currently I am doing this manually. Is there any way to generate this wrapper code through MatLab coder itself? If so then I can use the binary generated by MatLab coder directly in my application. I explored the possibility of including the “Custom C Code for Generated Files” but the content that I need to feed is static. I would like to know is there any way to generate the wrapper code for all the functions which is compiled from MatLab coder. I am trying to explore the “Code Replacement Library” option but didn’t get good example. Please throw some light on this area.
0 comentarios
Respuestas (1)
Sally Al Khamees
el 13 de Jul. de 2017
I do not think that there is a way to do this. You will probably have to do it manually.
See if the following link helps
it has some information on code replacement.
1 comentario
Royi Avital
el 14 de Sept. de 2019
It was really nice if there was an option to generate a code which an its entry point use regular types of C.
Namely regular pointers of C to arrays instead of the types defined by MATLAB.
To the leats you could add an auxiliray function which its input is a regular array of C and a vector of its dimensions and a scalar of the number of dimensions and its ouptut is the types of Coder.
At the moment coder yield a code which isn't fun to integrate to other projects.
Ver también
Categorías
Más información sobre MATLAB Coder en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!