Message Boards Message Boards

Compile your code for standalone projects?


I'm doing the Mathematica trial right now, and I'm having trouble finding information about deployment of the algorithms I create.

For example, say I create a new control algorithm for a power supply in Mathematica. How would I then "package up" my algorithm to work on a microcontroller in my actual product? I know that in MATLAB you can compile your code for deployment on other platforms, but it seems that compiling in Mathematica has a different meaning than that. I wouldn't want to have to completely re-write my algorithms just to deploy on my target system.

I found this tutorial that seems to be what I am looking for. Does the execution environment require the Mathematica kernel or is it entirely self contained?


23 days ago

I have never used this technology (so I do not have a very good understanding), but I am also interested in it.

It seems to me that the full Mathematica kernel is not required, but the generated program isn't standalone either. You need to link to the Wolfram Runtime Library (see "Libraries" -> "WolframRTL_Static_Minimal").

This means that the code can only run on systems for which Mathematica is available (i.e. Windows/OSX/Linux x86/x64 and Linux on ARM though the Raspberry Pi version), even if it doesn't require Mathematica to be installed. You need Mathematica to prepare the executable. Once that is done, you can move it to another computer which has the same architecture and operating system, and it will work there without Mathematica.

It also means that only a subset of Mathematica's functionality will be available for use. I was not able to find which subset is supported, but I am fairly confident that any compiled function that has a MainEvaluate call won't work this way. You can check this using

cf = Compile[...]; 

and look for MainEvaluate it in the output.

You may find it useful to look at:

While I said above that if a function is not compilable, then I'm fairly sure that it cannot be used in standalone executables, I am less sure about the reverse: I do not know if all compilable functions can be used in standalone programs. Perhaps someone who is familiar with the technology can clarify this.

POSTED BY: Szabolcs Horvát
23 days ago

I'm also very interested in this technology.

I don't have much to add than the hope that projects like the new compiler and an eventual WL free microkernel might bring some extra "consistency" on this front.

And although a microkernel might not be reasoned as a core subset...:

  • microkernel => small footprint => microcontroller

    eventually followed by

  • microcontroller => API call => whole set... (this line is obviously already possible, called from any microcontroller with internet access...)

POSTED BY: Pedro Fonseca
22 days ago

Wolfram doesn't offer a compiler to standalone APPs. However you can make CDF's or Enterprise CDF's (computable document format) that can be distributed, or you can deploy your software on the cloud + more

POSTED BY: Kay Herbert
21 days ago

Thanks for all the answers. It seems that like this isn't well supported, or at least not the intended use for Mathematica. I'm guessing Mathematica is meant more for analysis and learning.

20 days ago

Group Abstract Group Abstract