1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
|
\sec{Getting started}{getting-started}{Getting_started.html}
%
\subsection{Installation}
%
{\mlton} runs on a variety of platforms and is distributed in both
source and binary form. The format for the binary package depends on
the platform. The binary package will install under {\tt /usr} or
{\tt /usr/local}, depending on the platform. If you install {\mlton}
somewhere else, you must set the {\tt lib} variable in the {\tt
bin/mlton} script to the directory that contains the libraries ({\tt
/\prefix/lib/mlton} by default).
{\mlton} requires that you have the
\htmladdnormallink{GNU multiprecision library ({\gmp})}
{http://www.gnu.org/software/gmp/gmp.html}
installed on your machine. {\mlton} must be able to find both the
{\tt gmp.h} include file and the {\tt libgmp.a} or {\tt libgmp.so}
library. If you see the error message {\tt gmp.h: No such file or
directory}, you should copy {\tt gmp.h} to {\tt
usr/lib/mlton/self/include}. If you see the error message {\tt
/usr/bin/ld: cannot find -lgmp}, you
should add a {\tt -link-opt -L} argument in the {\tt usr/bin/mlton}
script so that the linker can find {\tt libgmp}. If, for example,
{\tt libgmp.a} is in {\tt /tmp}, then add {\tt -link-opt -L/tmp}.
Installation of {\mlton} creates the following files and directories.
\newcommand{\place}[1]{\item[\tt #1]\hspace{1in}\\}
\begin{description}
\place{\prefix/bin/mllex}
A lexer generator.
\place{\prefix/bin/mlprof}
A profiler (see \secref{profiling}).
\place{\prefix/bin/mlton}
A script to call the compiler.
This script may be moved anywhere, however,
it makes use of files in {\tt \prefix/lib/mlton}.
\place{\prefix/bin/mlyacc}
A parser generator.
\place{\prefix/share/man/man1/mllex.1, mlprof.1, mlton.1, mlyacc.1}
Man pages.
\place{\prefix/share/doc/mlton}
Directory containing the user guide for {\mlton}, mllex, and mlyacc,
as well as example SML programs (in the {\tt examples} dir), and
license information.
\place{\prefix/lib/mlton}
Directory containing libraries and include files needed during
compilation.
\end{description}
\subsection{Hello, World!}
Once you have installed {\mlton}, create a file called {\tt
hello-world.sml} with the following contents.
\begin{verbatim}
print "Hello, world!\n";
\end{verbatim}
Now create an executable, {\tt hello-world}, with the following command.
\begin{verbatim}
mlton hello-world.sml
\end{verbatim}
You can now run {\tt hello-world} to verify that it works. There are
more small examples in\\ {\tt \prefix/share/doc/mlton/examples}. In
particular, there are examples that demonstrate callcc, heap save and
restore, object size primitive, threads, profiling, and the C FFI.
|