Why Would You Use GCC, G++, or GFORTRAN?
Quoting from the Wikipedia article on the GNU Compiler Collection:
“GCC is often the compiler of choice for developing software that is required to execute on a wide variety of hardware and/or operating systems. System-specific compilers provided by hardware or OS vendors can differ substantially, complicating both the software's source code and the scripts which invoke the compiler to build it. With GCC, most of the compiler is the same on every platform, so only code which explicitly uses platform-specific features must be rewritten for each system.”
All of our Linux clusters provide gcc on the head nodes. The system gcc is matched to the version of the operating system and is not alterable. Thus, the older systems, hecate and woodhen, have a gcc 3 compiler, while all the rest have gcc 4. Additionally, every head node also has a matching version of g++, the Gnu C++ compiler. All except hecate have matching gfortran, the Gnu Fortran compiler. All except artemis have matching g77, the Gnu FORTRAN 77 compiler.
The Gnu C compiler, gcc, will translate ISO / ANSI as well as traditional C programs. The Gnu C++ compiler, g++, implements almost all of the ISO 2003 / ANSI 1998 C++ standard and a substantial portion of the C++ 200x draft standard. The Gnu Fortran compiler, gfortran, implements the ISO / ANSI Fortran 95 standard, making it able to compile almost every Fortran 77 program as well.
To compile a C source program named test.c into an executable program named test, use
gcc -o test test.c
To compile a C source program named gravity.c into an object file to be linked later, use
gcc -c gravity.c
To combine the C object files, main.o, tensor.o, matrix.o and vector.o into an executable program called algebra, use
gcc -o algebra main.o tensor.o matrix.o vector.o
Similarly, for a C++ program, use
g++ -o test test.cxx
g++ -c gravity.cxx
g++ -o algebra main.o tensor.o matrix.o vector.o
For a Fortran program, one might use
gfortran -o test test.f
gfortran -c gravity.f
gfortran -o algebra main.o tensor.o matrix.o vector.o
Programs written in Fortran 90 should be named ending with “.f90”, rather than “.f”
The main tool used to debug Gnu compiler suite programs is the Gnu debugger, gdb.