next up previous contents index
Next: Building Larger Programs Up: Invocation Previous: Source Files   Contents   Index

A First Example

Take your favorite text editor and put following lines in a file named HelloWorld.m2:

MODULE HelloWorld;

   FROM InOut IMPORT WriteString, WriteLn;

BEGIN
   WriteString("Hello World!"); WriteLn;
END HelloWorld.

This module may now be compiled and linked in a single step by the command m2c(1) which works very similar to cc(1) (with the exception of compiling Modula-2 instead of C, of course):

m2c -o hello HelloWorld.m2

The option -o hello tells m2c to name the resulting binary hello instead of the default a.out. You can now run it by just giving the command hello, provided your current directory is in the search path of your shell.



Andreas Borchert 2003-12-10