# Building and running example applications from the command line interface

### Check the current SDK device

Before starting to build an example application, you need to ensure that the S60 SDK device points to the device that the application in question is intended to run on. In other words, you need to make sure that the appropriate SDK installation is set as default.

To check the device, perform the following steps:

1. Open the command prompt and enter the following command and press enter:

   `devices`

   This command displays all Symbian SDK installations available to you, for example:

   `Nokia_Symbian3_SDK_v0.5:com.nokia.s60 - default`

   In the above, you can see that in this case the `Nokia_Symbian3_SDK_v0.5:com.nokia.s60` is the default (active) SDK (that is, the S60 5th Edition SDK 1). To switch between devices, use the `-setdefault` option of the `devices` command. Enter this command to switch to the S60 5th Edition SDK :

   `C:\devices -setdefault Nokia_Symbian3_SDK_v0.5:com.nokia.s60`

   Note: `@` is part of the command.

For more information, please, refer to SDK Help > Symbian Developer Library > How to Manage development for multiple device types for more information.

### Create the abld.bat file

Once you have checked that the current SDK is the default SDK, you need to create an `abld.bat` file. The `abld.bat` file is a batch file that controls the build process. The `abld.bat` file is generated from the `bld.inf` component description file.

To create the `abld.bat` file, perform the following steps:

1. Open the command prompt and go to the application top-level folder.

   For example, `<S60_SDK_installation_directory>\S60CPPExamples\helloworldbasic`

2. In the application top-level folder, locate the `group` subdirectory which contains the `bld.inf` file.

   For example, `<S60_SDK_installation_directory>\S60CPPExamples\helloworldbasic\group\`

3. Enter the following command and press enter:

   `bldmake bldfiles`

   This will create the `abld.bat` file in the current directory, making the `abld` command available for use.

In the following, you will use the command in creating build files and building the Hello World Basic example application. To find more information on other commands and switches, enter the `abld` command without arguments, for example:

`<S60_SDK_installation_directory>\S60CPPExamples\helloworldbasic\group\abld`

The help message printed to the console provides more information on the command and its parameters.

### Create the build files and build the application

With the `abld` command available, perform the following steps to create the needed build files:

1. Open the command prompt and go to the application folder, which now contains the `abld.bat` file.

   For example:

   `<S60_SDK_installation_directory>\S60ECPPExamples\helloworldbasic\group\`

2. Enter the following command and press Enter:

   `abld build winscw udeb`

Notice, that you have now built a debug build of the Hello World Basic example application (that is, debug-type binaries), which you can run on the emulator. This build is appropriate for your purposes at this point, as it enables you to run and view the application on the S60 emulator.

The build process creates the necessary build files and application binaries, including any resource files required.

This stage of the process may produce warnings. If there are errors, it may be because the exports of a DLL component were not frozen. If the application has a DLL component, you need to freeze the exports by performing the following steps.

1. In the application group folder, enter the following command:

   `abld freeze`

   For example,

   `<S60_SDK_installation_directory>\S60CPPExamples\SIPExample\group\abld freeze`

   This ensures that the exports are frozen. To use the frozen exported interfaces, the application needs to be re-built after the freeze.

2. Rebuild the application after freezing the exports by entering the build command:

   `abld build winscw udeb`

   For example,

   `<S60_SDK_installation_directory>\S60CPPExamples\helloworldbasic\group\abld build winscw udeb`

### Launch the application in the emulator

To run the example application that you have built on the S60 SDK emulator, perform the following steps:

1. Run the emulator by entering the following command in the command prompt:

   `epoc`

   This opens the S60 emulator.

2. In the emulator, click the Applications button to open the application grid.

3. In the application grid, navigate to the Installed folder with the five-way navigation key.

4. Open the Installed folder either by:

   - clicking the center of the five-way navigation key or

     clicking the left soft key (under Options) and then selecting Open from the menu that appears.

5. Once the Installed folder has been opened, use the five-way navigation key to locate the icon of the application in question (in this case Hello World Basic):

6. Click the left soft key under Options to open the application.

   You can scroll the menu options with the five-way navigation key and select them by clicking Select (right soft key).

7. With Open highlighted on the menu (see figure above), click the center of the five-way navigation key or the left soft key under Select to open the Hello World Basic application.

8. Click the left soft key under Options.

9. With Hello highlighted in the menu, click the left soft key under Select.

   The "Hello!" message is, in effect, what the Hello World Basic application consists of from the user's point of view. Once the message clears from the screen you can view it again by clicking the left soft key under Options and going through steps 5 and 6 again.

Once you return to the application grid, feel free to explore the emulator and its functionality. The emulator works like a real S60 device: click the keys in the emulator as you would press the keys on a real device. Use the five-way navigation key to select applications and open them by clicking the center of the five-way navigation key or Select under the left soft key. Exiting applications happens typically by clicking the right soft key.

Note: With a multi-SDK installation, the `epoc` command is an SDK-independent stub that launches the emulator application for the SDK device that is currently set as the default. Make sure that you are using the appropriate default device, as described in Check the current SDK device.

It is also possible to start the emulator from the Start menu by selecting, for example, Start > All Programs > S60 Developer Tools > 5th Edition SDK > v1.0 > Emulator. This will start the designated emulator application regardless of the current device settings.