PREV UP NEXT StackThreads/MP: version 0.77 User's Guide

2.2: Compiling

Compile the sample program in the previous section (call it fib.c) by:

        % stgcc fib.c -o fib

We use a simple frontend driver for gcc, called stgcc (stg++ is provided for C++ programs). It is NOT a preprocessor, but a simple script that invokes gcc with appropriate options (such as include search paths and library search paths). Also, it automatically links the StackThreads/MP library and utilities.

It is intended to accept ALL gcc options (unless it fundamentally conflicts with StackThreads/MP), so that any C program that can be compiled with gcc can at least be compiled with stgcc.

StackThreads/MP provides a small utility that generates a simple Makefile for new applications. Try:

                stmkmf "app_name" > Makefile

For example, if you want to create an application called "fib", you type:

                stmkmf fib > Makefile

The generated Makefile has some necessary settings such as CC=stgcc and some useful targets (such as clean). It assumes that you write a single source file (fib.c or fib.cc). For programs with multiple sources, look for BASES variable in the generated Makefile. Add base names of other object files there. For example, if the executable fib is going to be generated from fib.o, myutil.o, and main.o, you add util main to the BASES variables, like this:

        BASES = $(APP) util main

If you already have a Makefile for your program, do not bother to generate it and merge it into the old one. The generated Makefile does nothing particularly important. Simply set your CC variable to stgcc in your original Makefile.