Is mcc a cross-compiler?

8 views (last 30 days)
Maura Monville
Maura Monville on 1 Feb 2021
Commented: Walter Roberson on 1 Feb 2021
I am developing a Matlab code on my Mac.
I was asked to generape an executable that can be run on Windows.
I have read Kaustubha Govind' s answer dated November 9, 2018.
I understand MatLab comes witha compiler for scripting language "mcc".
I understand I have to install the MATLAB Compiler Runtime (MCR).
What is not clear is where I need the MCR.
Do I need the MCR on my Mac or do I need the MCR on the Windows workstation where the execuable will be run?
Furthermore, if I produce an executable on my Mac, using a MatLab version for Mac, then will such an executable be running on a Windows platform? I fesr that execuables generated on a Mac can only be run n a Mac.
Please, advise.
Thank you
Maura M. (maura.monville@nhs.net)

Accepted Answer

Walter Roberson
Walter Roberson on 1 Feb 2021
You need to compile on the same operating system as the program will be executed on.
For example you could install Bootcamp and Windows 10, use your MATLAB license there (same license because it is the same host) and build for execution on Windows.
  2 Comments
Maura Monville
Maura Monville on 1 Feb 2021
Thank you so much.
You have confirmed what I feared. That is "mcc" is not a cross-compiler".
Can you please confirm I have to download the MCR on the target platform (Windows) before compiling my code or just to run it?
Is the MCR included in a standard MatLab installation? I have all the toolboxes even if I only used 30% of them.
Thank you very much
Walter Roberson
Walter Roberson on 1 Feb 2021
MATLAB Compiler and MATLAB Compiler SDK include MCR. Historically you could choose to bundle MCR inside the executable or to not bundle it, in which case you either had to send it to the user separately or else the user had to install it from Mathworks. I am not sure whether the option to bundle it in the executable is still present.
MCR is needed to execute the resulting executable. Technically speaking, I am not sure it is needed to also compile the executable, but as the person doing the compiling would want to test the executable at least once, effectively it becomes mandatory on the host doing the compiling. But it is also a moot point because it is included inside the only two products that you can use to compile with to generate an executable, so it is going to be there anyhow unless you delete it.
MCR is not a development environment: it is the Mathworks Component Runtime, used to execute only.

Sign in to comment.

More Answers (0)

Categories

Find more on C Shared Library Integration in Help Center and File Exchange

Tags

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!