Go to the first, previous, next, last section, table of contents.

Simple Compile Example

Here we describe how you can compile a simple program using "cm3".

The easiest way to build packages is using CM3-IDE. Visit the Create Package form to create a new package within the CM3-IDE environment. CM3-IDE will allow you to select a package root (where your package will reside), package name, and package kind, before creating the package. Once you have created a package, you may use the Build button to compile its sources.

You can also create and compile sources without using the CM3-IDE environment. The instructions in this tutorial will guide you through creating and compiling a package by hand, from a Unix command-line shell. Creating a package by hand on a DOS command-line shell on Win32 platforms is also similar.


Using the Command Line Interface

What if I you wanted to use the command line interface? Here we describe how to build a simple program that we presented earlier in Writing Programs. First, you need to create a package directory for this program. Let's say you create a directory ~/proj/simple for this purpose. Then you need to create a subdirectory called 'src' in that directory to hold the m3makefile and source code file Main.m3. (You don't have to create an "src" directory, but most Modula-3 packages do so as a convention.) 

So you should have the following two files in the given directories:

While in ~/proj/simple directory, issue the "cm3" command to build your program. If your m3makefile is correctly formatted and the Main.m3 is correct, the compiler will create a build directory ~/proj/simple/TARGET (where TARGET is the name of your platform, e.g., SPARC or NT386) and place in it the executable file myprog. To execute the program, enter the command SPARC/myprog at the command prompt.


Tools for Building Small and Large Programs

For very simple program such as this one, you could have easily created an Main.m3 file, and just typed:

at the command line, even without an m3makefile.

For large programs, however, you will find that the structuring tools available with Modula-3 will help you easily create very sophisticated multi-platform programs.


Go to the first, previous, next, last section, table of contents.