matlab compiler vs mcc functionality
Afficher commentaires plus anciens
Hi, I am testing out the matlab compiler and the mcc function. I cannot get a full overlap of functionality between them. For example:
When using the mcc function, is there a way to include matlab runtime in the package, and specify the name of the installer executable? That is, the equivalent of the check box and edit field at the top of the compiler.
When using matlab compiler, is there a way to specify conversion of m files to p code (the '-p' option)?
Also, how do I validate that my compiled executable is using p code rather than m files?
I noticed some behaviour with matlab compiler regarding precedence that I think is contrary to the documentation. If the m files are in the same folder as the main file, then the m files take precedence over p code files, otherwise p code files take precedence. I suspect it is not matlab's intention that you create the p code files separately prior to compiling the executable, as I could not get this to work using mcc or compiler. I can only get it to work using mcc on m files with the '-p' option on. Some better examples or guidance would help here, as I am testing out lots of different ways to do things in the hope of finding what works.
Apologies if this is too many questions in one post.
Réponses (1)
Dirk Engel
le 27 Avr 2024
1 vote
I assume that by "MATLAB Compiler" you are referring to the MATLAB Compiler user interface (deplytool) which you can use to build and package your app. mcc only covers the build step, not the packaging. That's why there is no full overlap between the two.
Use the -o option of mcc to specify the name of the final executable.
Note that the compiled application contains encrypted files with the .m extension, but these are no normal m-files. They are neither human-readable, nor can they be be decrypted (to the best of my knowledge), nor can they be taken from the compiled app and used in a different context such as in MATLAB or in another compiled app. The files are encrypted with a key that changes with each compilation, so they only work in the context of that one specific compiled app. There is no need to create p-code before compilation. Your intellectual property is well protected in a compiled app.
5 commentaires
CM
le 27 Avr 2024
Déplacé(e) : Walter Roberson
le 28 Avr 2024
Dirk Engel
le 30 Avr 2024
Modifié(e) : Dirk Engel
le 30 Avr 2024
p-files will also be decoded in memory, so any additional layer of protection against a serious hacker is hypothetical. For the "average hacker", the task is probably already too difficult.
The installer for MATLAB Runtime (aka MATLAB Compiler Runtime, aka MCR) includes every built-in MATLAB function. It is not created specifically for your app but can be re-used by multiple apps. Installers are readily available from https://mathworks.com/products/compiler/matlab-runtime.html Just make sure to use the same release version you created your app with, or your app won't start. Given the size of the MATLAB installer (several GBs) I recommend that you do not package it with your app. Just use mcc to compile the executable of your app, and let the end user download MATLAB Runtime from the web resource and install it manually. The installation procedure is straight forward.
Walter Roberson
le 30 Avr 2024
"If someone is clever enough to get the decrypted files from "memory," would it then be a trivial task for them to unpack the p code into m code?"
Not trivial.
A small number of releases ago, Mathworks changed the pcode algorithm. It is not known how secure the current one is. It is known that a few people had reverse-engineered the previous algorithm; if anyone has reverse-engineered the current algorithm, then that is not public knowledge.
CM
le 30 Avr 2024
Catégories
En savoir plus sur Troubleshooting in MATLAB Compiler SDK dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!