Code Development
The C++ Programming Language
This workbook makes use of the C++ programming language, which is widely used in industry and academia. A tutorial of the C++ language is beyond the scope of this workbook. Instead, it is recommended to read a book on the subject:
- C++ How to Program
- The C++ Primer: A Gentle Introduction to C++, by M. T. Skinner
Or online tutorials:
Compiling Code
There are many methods to compile C++ code, the most basic of which is to directly call the c++ compiler. This method, however, is very tedious, requiring manual entry of numerous arguments every time the code is compiled. Alternatives to this approach involve defining a configuration file that a separate program parses and in turn calls the c++ compiler. This one level of abstraction greatly improves efficiency of the compilation process. One of the most common programs used to compile programs is called "make". While "make" has deep roots, it also has a very steep learning curve. This workbook utilizes a more modern compilation and configuration system called scons.
Scons is built on the Python programming language, which gives Scons great flexibility and simplicity. If you would like to learn how to write your own configuration files for Scons, visit their website at http://scons.org. For each exercise in this workbook an Scons configuration file is provided, and you'll only need to know how to execute Scons.
By default, the scons program will look for a file called SConstruct in the directory from with scons is executed. The SConstruct file informs scons how to process the source files in order to build an executable. The build process is started by running scons from the command line in the directory that contains an SConstruct file:
$ scons
Scons produces text output informing the user what it is doing. In our case scons will be running the c++ compiler to compile and link the source files specified in the SConstruct config file.
It is also possible to have scons clean-up the current directory by removing old object files (produced during compilation). This is achieved by passing the -c argument to scons:
$ scons -c
Again Scons will inform the user as to what it is doing through textual output.
Handling Compilation Errors
Many times the build process will fail, due to errors in the code. When scons runs into a problem the file and line number on which the error occurred is displayed along with a brief error description. These errors messages a usually very informative, and you will be able to determine what caused the problem. However, fixing compilation errors is a little bit of an art, and practice makes perfect. Remember that if you have a compilation error, someone else probably has had the same or similar experience. So use google and this workbook's mailing list to help solve any of your problems.
![[LOGO]](/workbook/skins/workbook/create_small2.png)



