Generating C/C++ Code from M-Function include MEX-File
Show older comments
Hi. Is it possible to generating C/C++ Code and Standalone-Application from a M-Function include MEX-File?
I try it like this.
function result = callfunction %#codegen
result = uint32(0);
result = Addi_mex(2,3); %call a mex-file
end
The MEX-Function is written in C++
#include "mex.h"
#include "mexhelper.h"
void mexFunction( int nlhs, mxArray *plhs[],int nrhs, const mxArray *prhs[])
{
ULONG sum=0, value1=0,value2=0;
// check Inputs
...
// Convert input data to unsigned integer via Matlab-function
...
sum = value1+value2;
plhs[0] = mmCreateMxArray(sum);
}
And Build to "Addi_mex.mexw32" with "mex -g -D_WIN32_WINNT -I ..." (MVS2010)
In the Workspace it works fine, but if I try to generate code or Standalone-Application from the function "callfunction.m" I get an error:
>> coder -build coder.prj
??? Only MATLAB files are supported for code generation. Unsupported file extension 'mexw32' for 'C:/.../coder_add/Add_mex.mexw32'.
I use the Matlab Coder. Is it maybe possible with the Matlab Compiler? And is it also possible to use in the MEX-File some other lib`s or dll`s? (in workspace seems to do)
I hope someone can help me.
Accepted Answer
More Answers (0)
Categories
Find more on MATLAB Coder in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!