Compiling and Running Simple Programmes with GCC


Solaris and Linux

Use your favourite editor (GNU emacs) to create a C source file, e.g., my_prog.c. Compile with
    gcc -o my_prog my_prog.c
to produce my_prog (omit -o my_prog for a.out).


MS Windows (Cygwin)

The best way to use GCC on MS Windows is first to start the bash command-line shell:
     set PATH=M:\Cygwin\bin;%PATH%
     M:\Cygwin\bin\bash --login -i
Next we need to set some mount points so that the compiler will be able to find bits and pieces it needs:
    mount m:\\cygwin /
    mount m:\\cygwin\\bin /usr/bin
    mount m:\\cygwin\\lib /usr/lib
N.B. Use lowercase and "escape" the backslashes; Ignore error messages if they say "mount point does not exist".
    cd /cygdrive/p
    mkdir my_c_src
    cd my_c_src
Having created a C source file and saved as, for example, P:\my_c_src\my_prog.c, compile with the command
    gcc my_prog.c -o my_prog
which will produce my_prog.exe. If -o my_prog is omitted a.exe is produced.


...previousup (conts)next...



About this document:

Produced from the SGML: /home/isd/public_html/_course_crash_in_c/_reml_grp/index.reml
On: 3/3/2003 at 17:43:41
Options: reml2 -i noindex -l long -o html -p multiple