Compiling is the act of taking a source code text file and running it through a compiler program to produce a program that can run on the computer.



Programmer writes the source code in plain text, often in an IDE (Integrated Development Environment)


The program is then compiled (converted) to a language that the computer can understand, and run as a program.


This is normally a two step process that consists of:

  1. Pulling in any specified header files and creating Assembly (or object) code native to the processor
  2. Using a linker program to pull in any other object or library files required, to finally output machine code (1's and 0's)

This resulting code is usually known as a binary or executable file.


The program can then be run (or executed) on the computer.


The GNU C++ compiler is invoked by opening a terminal and entering g++ on the command line.


Typically g++ takes at least two arguments; the file to be compiled and the output name:


g++ hello_world.cpp -o hello_world


*in windows, the output file type would need an .exe extension added to tell windows that its an executable program:


g++ hello_world.cpp -o hello_world.exe

Leave a Reply