How to auto generate wrapper for MatLab coder generated file?

1 Ansicht (letzte 30 Tage)
Murali Kannan Thiraviam
Murali Kannan Thiraviam am 10 Jul. 2017
Kommentiert: Royi Avital am 14 Sep. 2019
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.

Antworten (1)

Sally Al Khamees
Sally Al Khamees am 13 Jul. 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 Kommentar
Royi Avital
Royi Avital am 14 Sep. 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.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu MATLAB Coder finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by