This is documentation for Mathematica 4, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)
Wolfram Research, Inc.

How MathLink Is UsedSetting Up External Functions to Be Called from Mathematica

2.12.2 Installing Existing MathLink-Compatible Programs

One of the most common uses of MathLink is to allow you to call functions in an external program from within Mathematica. Once the external program has been set up, all you need do to be able to use it is to "install" it in your current Mathematica session.

Setting up external programs with functions to be called from within Mathematica.

This installs a MathLink-compatible external program called bitprog.

In[1]:= Install["bitprog"]

Out[1]=

BitShift is one of the functions inside bitprog.

In[2]:= BitShift[111, 3]

Out[2]=

You can use it just as you would a function within Mathematica.

In[3]:= Table[BitShift[111, i], {i, 30, 35}]

Out[3]=

When you have a package written in the Mathematica language a single version will run unchanged on any computer system. But external programs typically need to be compiled separately for every different type of computer.

Mathematica has a convention of keeping versions of external programs in directories that are named after the types of computers on which they will run. And assuming that this convention has been followed, Install["prog"] should always install the version of prog appropriate for the particular kind of computer that you are currently using.

Using context names to specify programs to install.

When you ask to read in a Mathematica language file using <<name`, Mathematica will automatically search all directories in the list $Path in order to find a file with the appropriate name. Similarly, if you use Install["name`"] Mathematica will automatically search all directories in $Path in order to find an external program with the name name.exe. Install["name`"] allows you to install programs that are stored in a central directory without explicitly having to specify their location.

How MathLink Is UsedSetting Up External Functions to Be Called from Mathematica