Compilers
Compiling using GNU C++ Compiler
cplusplus.com

PREVIOUS NOTE: This small text assumes that your compiler has already been installed and configured. Otherwise refer to the install information that comes with your distribution.

Compiling

This compiler can perform preprocessing, compilation, assembly and linking of a project from a single call to g++. Its format is:
g++ options_and_filenames
where options_and_filenames is a sequence of options and filenames that can be mixed in the command line.

The most common way of calling g++ to compile a single source file in C++ is:

g++ sourcefile -o execfile
where sourcefile is the C++ source file to compile and execfile is the name of the output file, generally the executable file, which must always be preceded by the -o option.

The type of file assumed when specifying a sourcefile depends on its extension, that must be: .C, .cc or .cxx for C++ source files. Additionally, the most recent versions of GNU C++ Compiler assumes also .cpp and .c++ extensions for C++ source files. .ii files are considered preprocessed C++ files.

You may also specify that a file is a C++ source file by preceding its name with specifier -x c++. For example, if we want to compile a source file with no-extension called mysource we may call g++ thus:

g++ -x c++ mysource -o myexec
©The C++ Resources Network, 2000 - All rights reserved
Return back