Most Research Computing Linux computers have three different kinds of compilers: GNU compilers, Portland Group compilers, and Intel compilers.
Below is a table that shows the different compilers and their commands:
|
Language |
File Suffix |
Command |
Type of Compiler |
|---|---|---|---|
|
Fortran 77 |
.f |
pgf77 |
Portland Group |
|
|
.f |
ifort |
Intel |
|
|
.f .F .for |
gfortran |
GNU |
|
Fortran 90 |
.f .f90 |
pgf90 |
Portland Group |
|
|
.f .f90 |
ifort |
Intel |
|
C |
.c |
pgcc |
Portland Group |
|
|
.c |
icc |
Intel |
|
|
.c |
gcc |
GNU |
|
C++ |
.c .C |
pgCC |
Portland |
|
|
.c |
icc |
Intel |
|
|
.c |
g++ |
GNU |
No one compiler works best for all kinds of code. If you are interested in optimizing your application, you will want to test various compiler options and compilers to see which ones work the best for your application. There is a man page for each compiler that lists the compiler options.
In general, gcc/g++ is the most flexible since it runs on a variety of different computer platforms. Many people use gcc/g++ so it will be easy to port their code to other platforms. g77 and gfortran are the Fortran77 GNU compilers and is not as robust as the Portland Group and Intel Fortran compilers.
The Portland Group compilers will compile f77, f90, C, and C++ codes. Many Fortran codes use extensions to the language, and the Portland Group compilers support those extensions. Portland Group recommends you use the pgf90 for both Fortran 90 and Fortran 77 codes to gain additional code speed up.
The Intel compilers do a good job of compiling code to make use of the architectural features of the Intel processors.
Here is a table of frequently used compiler flags, common to the above compilers.
| Compiler Option | What the option does |
| -c | Produce an object file only |
| -o filename | Create an executable called filename(the default is a.out) |
| -O {0,1,2,3} | Specify the optimization level ( 0 is none and 3 is most aggressive) |
| -g | Include a symbol table, needed for debugging |
| -pg | Generate profiling code |
| -I | Look for include files in this directory (default include directory is: /usr/include) |
| -L | Look for libraries in this directory (default library directory: /lib, /usr/lib, /usr/lib64 |
| -larchive | Link in a library called libarchive.so (or .a) |
| -static | Link only with static libraries (compilers use shared libraries by default) |
In general, you should use either the debugger that is supplied with each type of compiler or a general-purpose debugger like totalview. The table below provides the compilers and their associated debuggers for the compilers installed on the Research Computing Linux Computers.
|
Compilers |
Debuggers |
|---|---|
|
GNU gcc, g++ |
gdb |
|
Portland Group pgcc,pgf77,pgCC,pgf90 |
pgdbg |
|
Intel compilers icc, ifort |
idb |
|
Java compiler javac |
jdb |
|
Works with GNU, Intel, and Portland Group Compilers |
Totalview |
All of the compilers can be used in three different modes: To interactively
run and debug a program, to debug a core file that was created by a program, or
to connect to a running process. The documentation for each debugger provides
information about how to run them.
gdb is the debugger used for code compiled with the GNU compilers gcc and g++. It can be run from the
command line, from emacs or xemacs, from ddd or from eclipse.
pgdb is the debugger for the Portland
Group compilers. If you are running X Windows, pgdb has a graphical user
interface; otherwise, it has a command-based interface.
idb is the debugger for the Intel compilers.
It can be configured to run using the gdb or
dbx commands. It can be run with a command-based interface,
from emacs, xemacs, or ddd.
jdb is the command line debugger for java.
TotalView is a powerful GUI-based debugger that works with several compilers, including the GNU, Portland Group, and Intel Compilers. It can debug MPI, OpenMP, and other threaded C/C++ or Fortran programs.
A 64-bit computer can handle more computations, memory,
and I/O than a 32-bit computer. To take advantage of this additional power,
software must be built with 64-bit compilers. The 64-bit computer can run
32-bit applications, but running them in 32-bit mode doesn't use all the
expanded capabilities of the 64-bit computer. However, software built to use a
64-bit computer cannot run on a 32-bit computer.
All of the C/C++ and FORTRAN compilers on the public 64-bit Linux
computers will build 64-bit applications by default when you run them on
a 64-bit computer. You can specify options to these compilers to build a 32-bit
executable instead of a 64-bit. The table below provides more information on
these options for the installed compilers.
If you plan to build your application on both 32-bit and 64-bit
Linux computers, and you want to use the same executable on both, compile the
program for a 32-bit computer. If you plan to run only on a 64-bit
computer, compile the program for 64-bit, as it will run more
efficiently.
The File command tells you which kind of application your
executable is. For example, the following information is about an executable
called shapley.
file shapley
shapley: ELF 64-bit LSB
executable, AMD x86-64, version 1 (SYSV).
for GNU/Linux 2.4.0, dynamically linked (uses shared libs), not stripped
If you try to run a 64-bit executable on a 32-bit computer, you will get an error message that says, "Exec format error. Wrong Architecture.".
|
Compiler |
64-bit |
32-bit |
|---|---|---|
|
GNU C |
gcc |
gcc -m32 |
|
GNU C++ |
g++ |
g++ -m32 |
|
Portland Group C |
pgcc,pgf90 |
pgcc -tp px |
|
Intel C/C++ |
icc |
icc -m32 |