Mathematica 9 is now available
Student Support Forum
Student Support Forum: 'Mathlink c++ help wanted' topicStudent Support Forum > General > Archives > "Mathlink c++ help wanted"

Next Comment >Help | Reply To Topic
Author Comment/Response
06/28/05 10:19am

Hi, I want to make a c++ program (console) where i typ in a string/expression, it should be sent to mathematica/mathkernel and returned to the program and answer should be printed.

Ive tried and think i've got a connection to mathematica established but not been able to get a valid output.

So what i want is somthing like:

string evalstring;
string answer;
cin >> evalstring;
// send string here for evaluation to mathematica
// get the answer back
cout << answer;

About as far as Ive done is something like:

#include <iostream>
using namespace std;
#include <mathlink.h>
#pragma comment(lib, "ML32I2M.LIB")

int main(int argc, char *argv[])
MLENV env;
MLINK link;
long err;

env = MLInitialize(0);
// here i want to replace with MLOpenString so i dont have to type in and open mathkernel manually every time i run the program
link = MLOpenArgv(env, argv, argv+argc, &err);

string evalstring;
string answer;
cin >> evalstring;

// Its here i need all the help to send/recieve answer to/from mathematica/kernel.

I've tried using "MLEvaluate and MLEvaluateString functions but i get linking errors :/ like:
error LNK2001: unresolved external symbol "int __cdecl MLEvaluate(struct MLink *,char *)" (?MLEvaluate@@YAHPAUMLink@@PAD@Z)

cout << answer;

return 0;

Help would be appreciated.

URL: ,

Subject (listing for 'Mathlink c++ help wanted')
Author Date Posted
Mathlink c++ help wanted John 06/28/05 10:19am
Re: Mathlink c++ help wanted Mikhail Kat 07/01/05 00:29am
Next Comment >Help | Reply To Topic