Calling Mathematica via MathLink multiple times
- To: mathgroup at smc.vnet.net
- Subject: [mg44709] Calling Mathematica via MathLink multiple times
- From: jsu at caltech.edu (Julius Su)
- Date: Fri, 21 Nov 2003 05:13:31 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
I would to call Mathematica from within a C program to evaluate a
lengthy function. (the reverse of the usual situation!)
To do this I am using MathLink, and I have written a test program
that successfully establishes a link with the kernel, calls the
function, and returns the answer. When the program exits though, the
link to the kernel dies and the kernel quits.
Is there any way to keep the kernel alive between MathLink
connections? This would be useful for storing persistent information,
and for avoiding reinitializing certain routines before each function
Possible (indirect) solutions:
1. I have used <<JLink` and the ShareKernel command to allow the
kernel to switch between multiple links, but I would then need a way
to (1) detect when connections are broken and create a new link and
(2) tell my C program which port to connect under.
2. I could set up a program that connects once to the Mathematica
kernel, then write another program that contacts the first via a
message queue and semaphores. There must be a simpler way though!
Prev by Date:
Re: [Integrate] Why two results of same eq. are different?
Next by Date:
Follow up: 3D Convex Hull
Previous by thread:
Next by thread:
Re: Calling Mathematica via MathLink multiple times