Mathematica 9 is now available
Student Support Forum
Student Support Forum: 'MathLink in C & Export' topicStudent Support Forum > General > "MathLink in C & Export"

Help | Reply To Topic
Author Comment/Response
03/28/12 11:21am

I wrote a small dynamic library in C for MacOSX which evaluates Mathematica expression using the C MathLink functions.
It works fine, except for the Export command: I want to export a plot to a file, but no file is created with this code:

MLPutFunction(lp, "EvaluatePacket", 1);
MLPutFunction(lp, "Export", 2);
MLPutString(lp, "/Users/martin/...../file.png");
MLPutFunction(lp, "ToExpression", 1);
MLPutString(lp, "Plot[x,{x,0,1}]");

while((pkt = MLNextPacket(lp), pkt) && pkt != RETURNPKT)

pkt = MLGetString(lp, &res);

The MLGetString correctly returns the path to the file, but no file is created, and the same code works fine when using the LinkRead/LinkWrite functions in Mathematica itself... Also, similar code without using Export works fine, so I have no idea what could be wrong here?


URL: ,
Help | Reply To Topic