Compiling using GNU C++ Compiler
|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.|
g++ options_and_filenameswhere 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 execfilewhere 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|