This is documentation for Mathematica 3, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)
 Documentation / Mathematica / Built-in Functions / New in Version 3.0 / System Interface  /
LinkLaunch

  • LinkLaunch[" prog "] starts the external program prog and opens a MathLink connection to it.
  • LinkLaunch[" prog "] runs prog as a subsidiary or child process to your current Mathematica session.
  • You can use a command such as LinkLaunch["math -mathlink"] to launch a subsidiary Mathematica kernel process from within your Mathematica session.
  • On most computer systems calling LinkLaunch[" prog "] multiple times with the same argument will start several prog processes running. On systems such as the Macintosh, however, only one program with any particular name can be running at the same time.
  • On some computer systems, LinkLaunch[ ] will bring up a program browser.
  • LinkLaunch returns a LinkObject.
  • The option LinkProtocol specifies the underlying data transport protocol to use.
  • LinkLaunch internally calls a function analogous to the MLOpenArgv() function in the MathLink library.
  • See the Mathematica book: Section 2.12.7.
  • See also: Install, LinkCreate, LinkConnect, LinkClose.

    Further Examples

    LinkLaunch launches and connects to a program that is aware of MathLink. Here we launch a copy of Mathematica; a reason for doing this would be for two or more kernels to cooperate in solving a problem. This command works on any platform except the Macintosh.

    In[1]:=

    Out[1]=

    On the Macintosh you need to make a duplicate of MathKernel because you cannot launch an application from a single file more than once. Single quotes must surround the pathname if it contains spaces. This would be the command on the Macintosh: link = LinkLaunch["'MathKernel copy'"]
    MathLink communicates using packets. When the second kernel starts up, it sends a packet containing the first input prompt to the program that launched it.

    In[2]:=

    Out[2]=

    To send an expression to the second kernel for evaluation, wrap it in an EvaluatePacket; the result comes back in a ReturnPacket. The Unevaluated around the expression keeps it from evaluating before it is sent.

    In[3]:=

    Out[3]=

    When you are finished, quit the second kernel.

    In[4]:=