CIS Logo SVC Logo

   Computing & Information Systems
   Department

 

Schoology Facebook        Search CIS Site      Tutorials

Software Design Using C++



Using the g++ Compiler under Linux


If you have the g++ compiler installed under Linux, you use something like the following at the command prompt to compiler a single-file program:


g++ -o sample sample.cpp

Note that the above places the output into an executable file named sample. (The name following the -o option is the name that is used for the executable.) The source code is in the sample.cpp file.

If you have a multiple-file project, use something like this:


g++ -o sample sample.cpp aux1.cpp aux2.cpp

This again places the output into an executable file named sample. The source code files were sample.cpp, aux1.cpp, and aux2.cpp.

To get a smaller executable you can add the -s option. This strips the symbol table off of the executable. Here is an example of the use of the -s option:


g++ -o sample sample.cpp aux1.cpp aux2.cpp -s

Back to the main page for Software Design Using C++

Author: Br. David Carlson with contributions by Br. Isidore Minerd
Last updated: August 27, 2009
Disclaimer