Source-Navigator allows you to build executable programs from the files in your project. Using Source-Navigator, you can compile your code, navigate to any errors, link your code, and, with your debugger, set up a debugging session to debug your code.
The compiler, make, and debugger must be installed on your machine before using these features. |
At the end of this chapter, there is a build tutorial for a command line-driven real estate trading game.
The building process compiles and links source files, such as libraries and executable files, to produce an output binary file.
There are four steps to building your program:
The minimum requirements for building source code include specifying which source files should be included, the directory in which the build should be stored, linking rules, debugging, and optimization flags, and included paths.
You can edit your code using Source-Navigator. This chapter explains compiling and linking. For information about external stand-alone debuggers, see either the Debugger chapter in this manual or your debugger's documentation.
Source-Navigator uses a utility called make. make combines a set of rules for compiling and linking code with a tracking mechanism for determining which files must be compiled.
Source-Navigator generates a makefile, which make uses to determine which commands need to be executed in order to build your program.
A build target is a conceptual object that contains information needed to compile and link a project. For example, hello.c is converted into hello.o before hello.exe is built. hello.o requires converting rules and information regarding which libraries to use to complete the conversion to hello.exe.
The first time you select Build Settings... , the Build Targets list is empty. After you create a target, its name appears in the list.
Choose Tools -> Build Settings... to start the Build Settings dialog.
Enter the name of the target in the text entry box and click the Create button. The Edit Target dialog opens. See Editing a Target.
Rename a build target by selecting the target, entering a new name, and clicking the Rename button.
To edit an existing build target, select the target and click the Edit button.
Duplicating a target is useful when a new target is only slightly different from an existing target. To duplicate an existing target, select the target in the Build Targets list and click the Duplicate button.
Delete a target by selecting it in the Build Targets list and clicking Delete. The target is removed from the listing.
In the Build Targets list, either select the target name and click Edit or double-click the target name. The Edit Target window opens.
The Build Directory, Target Type, and Tool Chain combo-boxes are common to the tabs accessed in the Edit Target dialog.
These store information about the target.
This is the directory where all files generated in the build process are initially stored. By default this is blank. To specify the directory, either type the directory path or click the "..." button. If you click the "..." button, the Browse for Folder dialog opens:
Select the directory to store the intermediate files. Click OK to close the dialog. The directory appears in the Build Directory field.
Use this combo-box to select the type of target to create. The options are executable and library.
A tool chain is a set of compilers, debuggers, and linkers. The default for Tool Chain is GNUPro (native).
To import files or directories into your currently active project, follow these steps:
Add files to the Target Files list by selecting them from the Project Files list and clicking the Add Files button. The files are copied into the Target Files list.
You can remove files from the Target Files section by selecting them and clicking the Clear button. To remove all of the files from the Target Files section, click the Clear All button.
Most libraries required for building targets are linked in automatically by the compiler/linker. If you know that your target requires additional libraries, use the Library Files tab to add them to your build.
Add additional libraries by clicking the Add... button. The Open dialog opens to the last directory you have looked at in this project. After you select a library and click Open, it appears in the library list.
To remove a library from the listing, select the library and click the Remove button. The library is removed from the build.
Libraries are linked in the order listed in the window. To change the order of libraries, select the library and click either the Move Up or Move Down button to change its linking order.
Click the Build Rules tab to configure each rule in the target.
A rule contains information required to compile files in a project. For example, a rule to compile a C file might contain information about which compiler and flags to use, as well as what the file is called after it's compiled.
This tab lists the rules for the specified target. Within the Build Rules tab, you can:
The Command Line for Selected Rule displays the command line for the selected rule. |
This column shows the currently enabled and disabled rules. To disable a rule, highlight the rule and click the Disable button. To enable a rule, highlight the rule and click the Enable button.
This button changes between Disable and Enable depending upon the state of the rule. |
This column displays the type of file the rule acts upon.
This column displays a description of the rule.
To edit a rule, select the rule from the rule listing. Click the Edit Rule button. The Build Rule Settings dialog window opens. The dialog title bar displays the extension for the files involved.
The Settings tab allows you to change the default settings for the rule.
Debug:
This controls the debug information generated by the compiler.
Warnings:
Controls the level of warnings the compiler generates. A stricter warning
ensures fewer problems with future compatibility. Set "Warnings as Errors"
to make sure the compile stops any time a warning is generated.
User Flags:
Enter flags not covered by the options listed in this screen. To add
macros, see the Defines Tab.