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?
-
I am not sure I understand your question completely. Do you need to call the Mathematica kernel from a C program, or [do you need to call some C functions from Mathematica](http://stackoverflow.com/q/8140869/695132)? – Szabolcs Dec 15 '11 at 09:02
-
I need to call mathematica kernel from a C program. – maximus Dec 15 '11 at 09:13
-
[Is this what you are looking for then?](http://reference.wolfram.com/mathematica/tutorial/RunningMathematicaFromWithinAnExternalProgram.html) – Szabolcs Dec 15 '11 at 09:31
-
not exactly. if you have a big mathematica notebook file, then it will be hard to convert all the input operators inside one by one to the C program. instead, I want to call the evaluate of all the notebook file and get the result from that evaluation. – maximus Jan 18 '12 at 07:35
-
I think you should clarify the question a bit. The lack of answers shows people don't really understand it (neither do I). If you are asking about converting Mathematica code to C code, well, `Compile[ ... , CompilationTarget -> "C"]` does do that in a way, but reusing the output source code is not going to be trivial at all (because it is intended to be loaded by the Mma kernel after compiled). Generally: no, it's not possible to convert a *notebook* to C code. – Szabolcs Jan 18 '12 at 09:14
1 Answers
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.