APPENDIX E1
************************************************************
* COMPILERS ON UNIX *
************************************************************
A) COMPILERS AND FILE NAMING CONVENTIONS:
a) The file containing our program must have the following
extensions:
.p for the pascal language
.c for the c language
.f for the fortran language.
.c or .cc for the c++ language
.cbl for cobol
b) The compilers are called:
pc for the pascal language
cc for the c language
f77 for the fortran language
g++ for the c++ language
ccbl for cobol
c) Except for cobol, the result of the compilation is saved
in the standard file: a.out
This file can be renamed before being executed.
For cobol, an object file is created under the name:
cbl.out. The file cbl.out is not executable, but is
interpreted when we execute: runcbl.
B) EDITING, COMPILING AND EXECUTING:
The naming conventions for the file containing our program
"ex1" and the respective compilers is given below :
------------------------------------------------------------
| Program ex1 |
------------------------------------------------------------
| language editing compiling executing |
------------------------------------------------------------
| pascal vi ex1.p pc ex1.p a.out |
| c vi ex1.c cc ex1.c a.out |
| fortran vi ex1.f f77 ex1.f a.out |
| c++ vi ex1.c g++ ex1.c a.out |
| cobol vi ex1.cbl ccbl ex1.f runcbl |
------------------------------------------------------------
C) COMPILER OPTIONS:
Some useful options include
-w to eliminate warnings
-o to rename the object file
Example 1: Suppression of warnings:
In this example, we use the option '-w' to suppress the
warning messages:
g++ -w ex1.c
will compile C++ program ex1.c and suppress warnings.
Example 2: Redirection of the code file:
Suppose you have created in directory /tmp a subdirectory
called after your login name (for example joe). Then:
g++ -o /tmp/joe/a.out ex1.c
^
|______ replace joe by your login name
will compile the C++ program ex1.c and save the object code
in the temporary directory:
/tmp/joe
^
|______ replace joe by your login name
D) COMPILING AN EQUEL PROGRAM:
EQUEL programs need to be preprocessed before they can be
compiled. The precompiler (named eqc) expects a file name
with extension: .qc
The precompiler produces a new file containing the C++
program. The file has the same name as the one we
preprocessed, but the extension is .c instead of .qc
eqc ex1.qc
g++ -w ex1.c /ingres/lib/libingres.a -lm -lc
E) COMPILING AN ESQL PROGRAM:
ESQL programs need to be preprocessed before they can be
compiled. The precompiler (named esqlc) expects a file name
with extension: .qc
The precompiler produces a new file containing the C++
program. The file has the same name as the one we
preprocessed, but the extension is .c instead of .qc
esqlc ex1.qc
g++ -w ex1.c /ingres/lib/libingres.a -lm -lc
F) LIBRARIES:
If you need to use a library, you need to add its name in
the compile command.
* The math library is invoked as: -lm
* The Ingres library is invoked as:
/ingres/lib/libingres.a
.bp