Can C-code generated by the MATLAB Compiler 3.0 (R13) on one platform be used on another platform?

3 views (last 30 days)
I want to use C-code generated on one platform by the MATLAB Compiler 3.0 (R13) to create a stand-alone executable or MEX-file on another platform. I would like to know if the C code generated by the MATLAB Compiler is machine independent.
I would like to compile and link the code (generated on another architecture) on a processor (card) for which MathWorks provides the C Math Libraries (e.g create the C code on a PC and compile and link it on a 68040 processor).

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 5 Aug 2010
This solution applies only to MATLAB Compiler 3.0 (R13) and earlier versions, for information regarding MATLAB Compiler 4.0 (R14) and later versions please see the related solution below.
The C-code generated from the MATLAB file code is the same, regardless of which platform converts the MATLAB file code to the C code (it is platform independent). Therefore, you can take the C-code generated on any platform that is supported by MATLAB Compiler and create stand-alone applications on any platform which is supported by the C Math Library. You can also use the C MEX-file code to build MEX-file executables on any platform where the MATLAB Compiler is installed (the MATLAB Compiler ships with the necessary MEX libraries).
You may also possibly be able to create object code with a cross compiler for a specific target platform. You can then compile the object code on the target platform with the C Math Libraries for that target platform.
Note: Although this was never tested, it may be able to work because the object code is only specific to the hardware and not the operating system.
When creating stand-alone applications, with the code generated with the MATLAB Compiler, you must link the object code (created on another platform with a cross compiler) with the C Math Libraries on the platform which contains the operating system for which the Math C Libraries were created. In other words, unless the 68040 processor has the same operating system as the machine for which the Math C Libraries were intended, it most likely will not work. When creating executable programs from the generated C-code, you must make it specific to the operating system (it is not just hardware dependent). The C Math Library will only work on platforms that can run MATLAB.

More Answers (0)

Categories

Find more on Troubleshooting in MATLAB Compiler SDK in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!