CPSC250A: Data Structures and Algorithms
Fall 2011: Compiling With GCC

To compile a C++ program use the command:

      g++ -c program.cpp
    

Where program.cpp is the name of the C++ file that you want to compile. This will create the object file program.o. Next, the program needs to be linked to its dependencies. To link a C++ program use the command:

      g++ program.o -o program
    

Where program.o is the object file produced from the compilation command and program is the name of the program to be created. Finally, to run the program use the command:

      ./program