MathGroup Archive 1992

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

Search the Archive

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>
#include "mathlink.h"	/* Include the MathLink header file. */

main()
{
	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. */
	
	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

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

OBJS = addinteger.o

CFLAGS = -I$(MATHINCLUDE)

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


Now, when I build the executable, I get the following responses:
___________________________________________________________________
cc -I/LocalApps/Mathematica.app/Library/Mathematica/MathLink/Includes  
-c addinteger.c
addinteger.c: In function main:
addinteger.c:13: warning: assignment of pointer from integer lacks a  
cast
cc -o addinteger addinteger.o  
-L/LocalApps/Mathematica.app/Kernel/MathLink -lML
/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  
"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]