Compiling and Building

Compiling and building programs

Once you have written a C or C++ program, you will probably want to build and run it. To compile the current file (if it is a C/C++ source file), click on the Compile button in the extended toolbar, choose the menu item Build->Compile, or press F9. The Message window will appear and list all the messages including any compilation errors. You can double-click on the error lines (displayed in red) to go to the particular line where the error occurred. You can define macros, specify include paths, and set the compiler options if you so wish. Compiling a file will save it first, then it will be compiled.

Compiling a file does not build an executable. It simply generates an object (*.o) file which is later linked to build the executable.

To build a file, click on the Build button in the extended toolbar, choose the menu item Build->Build, or press F10. This will again display the Message window listing all the messages that are encountered during the build. The build process will link your object file with libraries and generate the executable. You can specify the libraries to link with your file in the Compiler Options dialog (Settings->Compiler and Linker Settings …)

NoteNote
 

The build process will compile your file first if the object file is not up-to-date or it has not yet been generated. This means that you can build a file without first compiling it. However, when you are dealing with a project rather then a single file, compiling and building are entirely different concepts.