Compiling your first C program

You have to first set up your environment. Assuming that NCIHOME is set to the home for NCI codes, you need to include $NCIHOME/solib in your LD_LIBRARY_PATH and $NCIHOME/bin in your PATH. For example, here are the tcsh commands for setting these variables.

setenv PATH $NCIHOME/bin:$PATH

The c2s program generates SUIF2 files from C source files. It takes only one argument, the C source file. For example,

> cat > test.c
/* test.c - a simple C program */

int main( int argc, char * argv[])
   int a, *b;

   a = argv[0][0];
   b = &a;

   printf ("%d %d\n", a, b);

   return (12);
> c2s test.c
> ls
test.c  test.suif 
The resulting SUIF file bears the .suif extension.

In general, most of them time is spent poking and prodding the SUIF file. When you are finished and ready to generate binary code, you can use the s2c pass. The s2c pass generates C code from a SUIF file. This C code can be run through gcc or the Solaris cc compiler to generate object files and executables. For example,

>suifdriver -e "import s2c; load test.suif; s2c -D ARCH=SunOS test-out.c"
>gcc -o test test-out.c
46 -268437772

Constantine Sapuntzakis
Last modified: Thu Oct 28 11:41:34 PDT 1999