Message Boards Message Boards


Building Console Application Linking Mathematica

Posted 10 years ago
2 Replies
1 Total Likes
I am very new to Mathematica and I am trying to create a console application using Visual Studio C++. I have followed a example code to see whether it works or not. The codes are as follows.
 #include <mathlink.h>
 #include <stdio.h>
 int main(int argc, char *argv[]) {
     MLENV env;
     MLINK link;
     int errno;
     int packet;

    env = MLInitialize(0);

    /* consider using MLOpenString instead here: */
    link = MLOpenArgcArgv(env, argc, argv, &errno);


    /* send 42+137 using the full form Plus[42, 137] */
    MLPutFunction(link, "Plus", 2);
    MLPutInteger(link, 42);
    MLPutInteger(link, 137);

    /* get packets until we find a ReturnPacket or error */
    while ((packet = MLNextPacket(link)) && packet != RETURNPKT)

    if (MLError(link))
    else {
            int result;
        MLGetInteger(link, &result); /* we know that the result is an integer in this case */
        printf("result: %d\n", result);

    return 0;

When I run this code, it runs and gives me the dialogue boxes below. However, I am not sure what to key in there.

What link am I to create or link to? What am I doing wrong?


POSTED BY: Arvind Rajan
2 Replies
I think it's looking for MathKernel.exe
POSTED BY: Frank Kampas
yes, i solved it! thanks
POSTED BY: Arvind Rajan
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract