MathGroup Archive 1992

[Date Index] [Thread Index] [Author Index]

Search the Archive

MathLink Sample Program Problems


I'm working with the Mathematica Kernel version 2.0 on a NeXT cube.   
The 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>
#include "mathlink.h"	/* Include the MathLink header file. */

	int	i, j, sum;
	MLINK	p;		/* MathLink link descriptor. */
	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. */
	/* Tell Mathematica you have finished sending the input 

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

	   and evaluates it. */

	/* 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);
	/* End the Mathematica process. */
} /* main */

And here is my Makefile:
MATHDIR = /LocalApps/

MATHINCLUDE = $(MATHDIR)/Library/Mathematica/MathLink/Includes
MATHLIB = $(MATHDIR)/Kernel/MathLink

OBJS = addinteger.o


addinteger: $(OBJS)
	cc -o addinteger $(OBJS) -L$(MATHLIB) -lML

Now, when I build the executable, I get the following responses:
cc -I/LocalApps/  
-c addinteger.c
addinteger.c: In function main:
addinteger.c:13: warning: assignment of pointer from integer lacks a  
cc -o addinteger addinteger.o  
-L/LocalApps/ -lML
/bin/ld: Undefined symbols:
*** Exit 1

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  
"mathlink.h" and the MathLink libraries?

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]