Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I would like to write a small C program which starts a Mathematica session, executes some user defined code and retrieves the output and finally quits the session. Basically I like to have a simple custom made user interface for Mathematica based on standard C. I am confident that such libraries exist since I am using a program of this kind for Maple (based on OpenMaple libraries). I just do not know where to start. Maybe somebody can point me to the documentation. Ideal would be a small sample application. Maybe something like this ships with Mathematica?


Don't be confused by the comments. Eventhough the answer "see the Documentation" seems obvious here (as I ask for it), the by far best resource for the solution is on the Wolfram webpage. See also my answer below. As far as I can see it is neither referenced in the documentation nor contained in the builtin examples. Not knowing the words to search for it took some effort to find it.

share|improve this question
2  
You've seen MathLink? –  J. M. Jun 22 '12 at 17:15
6  
Sometimes I wonder why people not type "C program" or "C++" into the help browser in the first place. The documentation to "C/C++ Language Interface" would have been always one of the first hits.. –  halirutan Jun 22 '12 at 19:43
1  
No questions, no answers, no question-answer game. –  highsciguy Jun 22 '12 at 20:23
add comment

2 Answers

up vote 5 down vote accepted

I just found this example front end; it is pretty much what I need. It compiles just like the factor example in the Mathematica Documentation in $InstallationDirectory/SystemFiles/Links/MathLink/DeveloperKit/$SystemID.

share|improve this answer
add comment

Here is a link to some MathLink documentation. You'll want section Running Mathematica from Within an External Program from that overview.

In it there is a line that states:

The MathLink Developer Kit contains sample source code for several simple but complete front ends.

You should be able to be up and running quickly using these examples.

The first page mentioned above also provides links to system-specific setup procedures, for instance about how to complete the installation of the necessary stuff that came with MMA's installation.

share|improve this answer
1  
Thanks so far. I found it and made the factor "frontend" compile. What I miss now is a basic example for sending a string (presumably using MLPutString) and retrieving an output string. The examples I see mix sending/retrieving of various data types which I find a bit confusing. –  highsciguy Jun 22 '12 at 19:46
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.