Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2006

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

Search the Archive

Re: calling mathematica from an external program

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

peregrine_falcon12 at hotmail.com 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.

-Rob


  • 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