MATLAB: How can i add the C source code of a matlab function to a mexfunction of a matlab toolbox written withc/c++ code
mex-function
How can i add the C source code of a matlab function to a mex file of a matlab toolbox written withc/c++ code ?
the source code of the toolbox is not available.
Best Answer
If I understand your question correctly, you want to modify existing compiled code by adding your own code, but you don't have the source code for the existing compiled code. You cannot do that. You would need the original source files for the compiled code in order to add in your source code so that you could recompile the whole thing again. And, if this is an official MATLAB toolbox we are talking about, this would probably not be a good idea anyway.
What problem are you trying to solve? Why do you think you need to modify existing compiled code in order to solve your problem?
Going from .mex64 back to .cpp is not straightforward since all the information that makes code readable, such as variable names, are lost when compiling them. You would be better off asking for the source code or writing a mex function in c++ from scratch...
Here's another Q&A about reverse-engineering C++ code:
You can useMATLAB Compiler to deploy your application to a standalone executable. You can then give this to anyone and they can run it without MATLAB installed (though they will have to install the free MCR).
Alternatively, you can useMATLAB Coder to generate portable C-code from your MATLAB algorithm.
Best Answer