Clear[f,g]
Directory[]
fLink=Install["f.exe"]
gLink=Install["g.exe"]

Prebuilt Examples

There are a collection of prebuilt (i.e.  precompiled) examples.  They are in the following directory.

SetDirectory["/usr/local/Wolfram/Mathematica/7.0/SystemFiles/Links/MathLink/DeveloperKit/Linux/PrebuiltExamples"]
FileNames[]

link=Install["addtwo"]
LinkPatterns[link]
AddTwo[123,345]

link=Install["reverse"]
LinkPatterns[link]
reverseString["Plan"]

link=Install["sumalist"]
LinkPatterns[link]
SumAList[{1,2,3,4}]

link=Install["quotient"]

Building an Examples

OK.  The makefile does not work correctly.  It says it cannot find mprep but it can find mcc which should be what it uses.  I copied all the stuff to my sample directory and made a minimalist make file.

SetDirectory["/home/faculty/struther/Desktop/MathLinkExamples"]
link=Install["addtwo"]
LinkPatterns[link]
start=Date[];
AbsoluteTiming[AddTwo[1.2,3.4]]
Date[]-start

?Date

$Version

f[x_]:= Module[
{},
Pause[1]; 
Sin[x]
]

AbsoluteTiming[ f[1.2]]

ContourPlot[f[x,y],{x, 0, 3},{y,

Break

f[1,4]
g[1.2,2.2]
Uninstall[fLink]
Uninstall[gLink]

?Install

$SystemID

f[x_Real] = x*x

f[1]