Search code examples
wolfram-mathematicamathlink

How to create C code using Mathlink


I have studied examples of using mathlink from Visual Studio. The question is, I have a mathematica notebook file where the needed calculations are done. Now I want to make the same things but from my C program using Mathlink. Is there an automatic tool for converting the Mathematica notebook file to C code so that they will be called by using the mathlink?


Solution

  • I have a mathematica notebook file where the needed calculations are done. Now I want to make the same things but from my C program using Mathlink.

    You should probably read the answers to https://stackoverflow.com/questions/8140869/minimal-effort-method-for-integrating-c-functions-into-mathematica

    Is there an automatic tool for converting the Mathematica notebook file to C code so that they will be called by using the mathlink?

    The closest to an automatic conversion that I am aware of is using Compile with CompilationTarget -> "C" in Mathematica version 8.

    This is probably not what you want however, because it will require rewriting your code in a way that it can be handled by Compile. Further, it is automatically linking the function rather than embedding it in an external program.