Compiling C++

This page is under construction (TO DO) please return back later.

As you will know, C++ works by compiling source code into something that the computer can load and execute quickly.

The usual techniques are either (a) to compile and run from the command line or (b) to set up a project in an IDE and compile and run by clicking buttons. Which is better depends on what you want to do. Generally speaking IDEs help by having many styles of project already present and available for you and by preventing you doing something silly such as forgetting to save or forgetting to re-compile. On the other hand, IDEs make things more complicated by offering you a bewildering number of options you don't need, and (for more advanced work) by not offering you the exact style of project that you are working on as a preset.

We have covered the basic use of compilation from the command line. There is a page on the use of the Code::Blocks IDE for console applications.

C++ syntax is fussy and can be unforgiving. There are a number of pitfalls for beginners and experts alike. It can be helpful to get the C++ compiler to give you the maximum number of warnings for suspicious code. The GCC compiler does this with the -Wall option, and you compile myfile.cpp with c++ -Wall myfile.cpp -o myfile. This will increase the number of warning messages produced when a file is compiled. (Depite the name, -Wall is not all wornings, but most warnings.) This is strongly recommended. All IDEs have corresponding settings.