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.
Building the project
To buld the project, do the following:
- From the Project menu, click Build.
—or—
- On the Build tool bar, click the Build 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
CrossStudio compiled fact.c without errors, but main.c contains two errors. After compilation, CrossStudio moves the cursor to the line containing the first reported error. As well as this, the line is marked in the gutter and highlighted by underlining it red. (You can change this behaviour using the Environment Options dialog.)
The status bar also updates to indicate two build errors and shows the first error message.
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, compile the project again. The build log still shows that we have a problem.
Notice that fact.c has not been recompiled because it was compiled correctly before and is up to date. 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. Recompile the project—this time, the project compiles correctly: On the status bar, the code and data sizes required for the project are shown:
The numbers for your application may not match these exactly, so don’t worry if they don't. In the next sections we'll explore the characteristics of the built project.