How to build .m file into .mex file

5 views (last 30 days)
dukek
dukek on 24 Oct 2015
Answered: Rahul Goel on 28 Oct 2015
I know that Matlab Coder is recommended for the task in question. But I don't have access to that toolbox. I can compile the .m file into a C library that probably can be linked to build a mex file. I am wondering if there is any instruction or hints on how to do this? Basically to do things manually as what the Matlab Coder does. Thanks in advance to anyone who can shed some lights on this.
The purpose is to protect the m code. The security of pcode is apparently not good enough. Try google matlab depcode ...

Answers (1)

Rahul Goel
Rahul Goel on 28 Oct 2015
You can refer to the following documentation for linking "C" libraries during creation of "mex" files: http://www.mathworks.com/help/matlab/ref/mex.html#inputs
Also, creating a mex file from a C code and generating C code using MATLAB coder are two very different things. I doubt if the functionality of MATLAB Coder can be replicated by building mex files from C libraries. Mex files are built by creating a wrapper over your source code and allowing it to be used as executable on MATLAB platform. On the other hand MATLAB Coder generates the appropriated C code by evaluating each line of the source MATLAB code.
Hope this helps.

Community Treasure Hunt

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

Start Hunting!

Translated by