       MathLink Sample Program Problems

• To: mathgroup at yoda.physics.unc.edu
• Subject: MathLink Sample Program Problems
• From: ringgere at zapotec.math.byu.edu
• Date: Thu, 26 Mar 92 15:18:06 MST

```Hello.

I'm working with the Mathematica Kernel version 2.0 on a NeXT cube.
The Mathematica.app directory is installed in /LocalApps.

I have attempted to use the first two examples in a copy of the
Wolfram publication "The MathLink Communication Standard" by Arkady
Borkovsky.  On the copy I received from a professor here in the math
department, there is no indication of a publication number or date;
however, the introduction does mention kernel version 2.0, so I
assume that the document is reasonably recent.

Here is the C program I am trying to use:
___________________________________________________________________
#include <stdio.h>

main()
{
int	i, j, sum;

fprintf(stdout, "==>");
scanf("%d %d", &i, &j);

p = MLOpen("math -packets -batchoutput");
/* Start Mathematica in packets mode. */

MLPutFunction(p, "Plus", 2);
/* Send a Plus function that will have two arguments to

Mathematica. */

MLPutInteger(p, i);
/* Send the integer i. */

MLPutInteger(p, j);
/* Send the integer j. */

MLEndPacket(p);
/* Tell Mathematica you have finished sending the input

packet. */

/* Mathematica has now received the expression Plus[i, j],

and evaluates it. */

MLGetNext(p);
/* Get the head of the ReturnPacket from Mathematica. */

MLGetInteger(p, &sum);
/* Get an integer from the ReturnPacket, and store it in
sum. */

fprintf(stdout, "sum = %d\n", sum);

MLClose(p);
/* End the Mathematica process. */
} /* main */
___________________________________________________________________

And here is my Makefile:
___________________________________________________________________
MATHDIR = /LocalApps/Mathematica.app

CFLAGS = -I\$(MATHINCLUDE)

cc -o addinteger \$(OBJS) -L\$(MATHLIB) -lML
___________________________________________________________________

Now, when I build the executable, I get the following responses:
___________________________________________________________________
addinteger.c: In function main:
addinteger.c:13: warning: assignment of pointer from integer lacks a
cast
/bin/ld: Undefined symbols:
_MLOpen
*** Exit 1
Stop.
___________________________________________________________________

When I peruse the "mathlink.h" header file, I find no declaration of
the function MLOpen.

I encounter similar problems with the second example in Mr.
Borkovsky's document.

Is the document I'm working with out of sync with my version of

Any feedback would be appreciated.  If your responses come to me
directly, I will summarize the responses and post them on the group
for the benefit of those who are interested.

Thanks to all
--Eric Ringger

```

• Prev by Date: converting from base to base...
• Next by Date: [no subject]
• Previous by thread: converting from base to base...
• Next by thread: [no subject]