Now that the project is created and set up, it's time to build it. Unfortunately, there are some deliberate errors in the program which we need to correct.
Setting the build configuration
The first thing to do is set the active build configuration you want to use. To set the active build configuration, do the following:
- From the Build menu, click Set Active Build Configuration and select MSP430 Debug.
This signifies that we are going to use a build configuration that generates code with debug information and no optimisation so that it can be debugged. If we wanted to produce production code with no debug information and optimisation enabled we could use the MSP430 Release configuration however as we are going to use the debugger we shall stick with the MSP430 Debug configuration.
Building the project
To build the project, do the following:
- From the Build menu, click Build Tutorial.
—or—
- On the Build tool bar, click the Build Active Project tool button.
—or—
- Type F7.
Alternatively, to build the Tutorial project using a context menu, do the following:
- In the Project Explorer, right click the Tutorial project node.
- Select Build from the context menu.
CrossStudio starts compiling the project files but finishes after detecting an error. The Output Window shows the Build Log which contains the errors found in the project:
Correcting compilation and linkage errors
The file main.c contains two errors. After compilation, CrossStudio moves the cursor to the line containing the first reported error and displays the error message (You can change this behaviour by modifying the Text Editor > Editing Options > Enable Popup Diagnostics environment option using the Environment Options dialog).
To correct the error, change the return type of factorial from void to int in its prototype.
To move the cursor to the line containing the next error, type F4 or from the Search menu, click Next Location. The cursor is now positioned at the debug_printf statement which is missing a terminating semicolon—add the semicolon to the end of the line. Using F4 again indicates that we have corrected all errors:
Pressing F4 again wraps around and moves the cursor to the first error, and you can use Shift+F4 or Previous Location in the Search menu to move back through errors. Now that the errors are corrected, build the project again by pressing F7. The build log still shows that we have a problem.
The remaining error is a linkage error. Double click on fact.c in the Project Explorer to open it for editing and change the two occurrences of fact to factorial. Rebuild the project—this time, the project compiles correctly:
A summary of the memory used by the project is displayed at the end of the build log. The results for you application may not match these, so don't worry if they don't.
In the next sections we'll explore the characteristics of the built project.