MathGroup Archive 2006

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

Search the Archive

Re: calling mathematica from an external program

  • To: mathgroup at
  • Subject: [mg67097] Re: calling mathematica from an external program
  • From: "ragfield" <ragfield at>
  • Date: Fri, 9 Jun 2006 01:08:07 -0400 (EDT)
  • References: <e66640$n70$><e68q8f$d1a$>
  • Sender: owner-wri-mathgroup at

peregrine_falcon12 at wrote:
> I found this function MLEvaluateString, but when I try to compile my
> program, I get an "unresolved external symbol" message, but I think I'm
> including all the necessary libraries. Does anyone know what library
> the function is defined in, and maybe what could be causing this
> message?

MLEvaluateString() is automatically defined by the mprep program
included with MathLink, and mprep is typically only used for
executables which are called from Mathematica (not the other way around
as I believe you are trying to do).  It is defined as follows:

mlapi_packet MLAnswer( MLINK mlp)
	mlapi_packet pkt = 0;

	while( !MLDone && !MLError(mlp) && (pkt = MLNextPacket(mlp), pkt) &&
pkt == CALLPKT){
		MLAbort = 0;
		if( !MLDoCallPacket(mlp)) pkt = 0;
	MLAbort = 0;
	return pkt;
} /* MLAnswer */

int MLEvaluate( MLINK mlp, charp_ct s)
	if( MLAbort) return 0;
	return MLPutFunction( mlp, "EvaluatePacket", 1L)
		&& MLPutFunction( mlp, "ToExpression", 1L)
		&& MLPutString( mlp, s)
		&& MLEndPacket( mlp);
} /* MLEvaluate */

int MLEvaluateString( MLINK mlp, charp_ct s)
	int pkt;
	if( MLAbort) return 0;
	if( MLEvaluate( mlp, s)){
		while( (pkt = MLAnswer( mlp), pkt) && pkt != RETURNPKT)
			MLNewPacket( mlp);
		MLNewPacket( mlp);
	return MLError( mlp) == MLEOK;
} /* MLEvaluateString */

To make this work in your code you can just get rid of the MLAbort
variable, and the CALLPKT/MLDoCallPacket() stuff.


  • Prev by Date: Re: calling mathematica from an external program
  • Next by Date: Using Mathlink to export arrays
  • Previous by thread: Re: calling mathematica from an external program
  • Next by thread: matrix substitution