C under Linux

Revised 21/10/2002
On the University central Linux servers the C/C++ compiler command is gcc
though for simple compilations you can use the command: c

To create a file for example 'hello.c'

     $ edit hello.c
(The Linux Pico Editor will be opened. Type the following in the editor.)

To compile the file 'hello.c'
     $ c hello.c
or use gcc with -o option
     $ gcc hello.c -o hello
To execute the file 'hello'
     $ run hello

This will output Hello World!...

Infact, there are two modes of program execution; these are interactive (the commands nice and run), and background (the & symbol and the command submit). Note that there are no cpu time limits or batch queues. To run an executable program you can simple type its name or use the run command. For example, you have compiled a C program into an executable program called myprog. The program can be executed with one of the following commands:
     $ myprog
     $ ./myprog
(if myprog exists elsewhere in the user's PATH then './' specifies that the file to be executed is in the present working directory)
     $ nice myprog     (please use this one or the next to be nice to other users)
For our c program 'hello.c'
     $ hello
or
     $ ./hello
Notes:

Using Library by C

Before starting, create the following files to be an example:

sub1.c , sub2.c , sub3.c and main.c

Note: Known problems when porting C programs from other platforms (e.g. ALPHA, Sun)
  • Math library math.h:
    If you use math.h and you get compilation errors such as 'undefined reference to ...'
    then you need to compile either with the -O2 option or the -lm option; or use the c command.
  • .... more problems (with solutions) will be included as they appear;
    please report problems to me!
See also:
gcc_2.html
gcc.ps
gcc.ps.zip
http://www.gnu.org/software/gcc/gcc.html
http://gcc.gnu.org/onlinedocs/gcc-3.0/gcc.html
http://www.gnu.org/software/gcc/faq.html
system@gantep.edu.tr