The Artima Developer Community
Sponsored Link

Symbinia
Setting Up for Emulation
by Nancy Nicolaisen
January 8, 2008
Summary
You can learn a lot from observing little kids: Avoid the people your dog dislikes; chasing the cat is more fun than catching it; and ALWAYS look between the bread before you bite the sandwich. This last, in a nutshell, is why Symbian C++ developers need emulators.

Advertisement

Tooling Up for Emulated Debugging

Device emulation is an important tool because it can save you so much time. Using the S60 emulators, you can move through early phases of the design/code/test cycle for smartphone software almost as quickly as for desktop applications. It is, of course, ultimately necessary to do on-device debugging and testing, but emulation lets you weed out a good many problems before you get there. To a large extent, emulators are faithful representations of devices they proxy. They remove physical limitations and the potential for blocking introduced by debugging over the wire, executing emulated apps up to several orders of magnitude faster. It only makes sense to get as close as possible to the final product before you begin on-device debugging.

In this outing, we get our emulation mojo working, so to speak: We’ll use the command prompt window to ensure we have the correct Symbian SDKs installed. Next we’ll generate a basic Carbide C++ HelloWorld application so that we’ll have something to run on the emulator. We launch the app directly to emulation from the IDE and check configuration properties in a single step. In addition, we’ll try a standalone launch of the emulator from the command line.

Checking For the Correct SDK Versions

First, we verify that we have the correct Symbian S60 SDKs installed and configured. ( Check the previous post for a walk through if you haven’t already got them in place. )

• Open the command prompt

• Type: devices

This command displays installed Symbian SDKs. For my system it reports:

S60_3rd_FP1:com.nokia.S60

S60_3rd_FP1_2:com.nokia.S60 - default

Notice two things here. First, the S60_3rd_FP1_2.nokia.S60 is the default SDK. To change the default SDK using the command prompt window, use the -setdefault option of the devices command as shown below.

C:\ devices -setdefault @S60_3rd_FP1:com.nokia.S60

And second, notice that I have one more SDK than described in the setup steps in the last blog. For both of these two SDKs, there are stable Carbide.C++ emulators. Either of them will serve you for testing and exploring upcoming code examples. It is absolutely essential however, that the emulator and the compiled code match each other’s SDK version. To verify this, you can check project properties, run configurations or debug configurations, all of which are accessed by right clicking on the top folder in the project pane of the IDE.

Creating a Hello World Project to Test The Emulator

We need a simple application we can use to test the emulator installation and function. Wake up Carbide.c++ and follow these steps to generate a HelloWorld test app:

• From the main menu bar, select File.New

• Choose Project

• From the list of project types, choose Symbian OS C++ Project

• From that list, select S60 3rd Edition GUI Application. Note the checkbox labeled “Filter Templates based on available SDKs”. Keep this checked.

• Select the build target that corresponds to the emulator you have installed and designated as default.

Launching HelloWorld in the Emulator

From the Carbide Project Window, verify the emulator target by right clicking the project file and choosing Run As, and then choosing Run from the floating menu this summons.

This displays the Create, Manage and Run Configurations dialog. If everything is on track, here you’ll see the project name and two paths – one for the executable and one for the emulator. These paths should be identical up to the terminal elements. On my system, they look like this:

Project: HelloWorld

Executable: C:\Symbian\9.2\S60_3rd_FP1_2\Epoc32\release\WINSCW\UDEB\HelloWorld_0xE8414F81.exe

Emulator: C:\Symbian\9.2\S60_3rd_FP1_2\Epoc32\release\WINSCW\UDEB\epoc.exe

If the path strings differ at all before the final backslash, you have a mismatch between the emulator and the application. You can fix that by changing the emulation default or recompiling to target the current default emulator.

If you click the Run button at the bottom of the dialog, you launch the app in the emulator. This will give you time for around a dozen deep breaths, a quarter of a cup of coffee or a quick check of your email.

At this point, I typically receive an emulator status message which reads ”Application closed: ncnlist KERN-EXEC 3”. On the left side of the button bar you’ll see a control labeled “OK”. Click on the button below to clear the message and display the emulator home screen.

In the column on the left side of the emulator skin, click the third option button (below the camera button and above the scroll keys). This displays the menu screen. Navigate to the “Installed” icon, select it and you’ll see HelloWorld, along with any other apps that have been compiled to the emulator target. Select and run HelloWorld.

At the risk of being tedious, I’ll mention one thing which still snags me occasionally. You must navigate the emulator using its control keys. Once in a while I find myself furiously mousing over something on the emulator skin, clicking ferociously away, and seriously frustrated that nothing is happening. So. Pretend it’s a real phone. Use the directional keys and selection button.

Launching From the Command Line

I have noticed that multiple app launches from the Carbide IDE sometimes cause the emulator to feel exactly like I do after shoveling way too much snow for three days running: “Device Won’t Start”. There is an easy work-around for this problem (the emulator balking, not my unwillingness to keep digging ) because the emulator is a standalone tool. You can launch it from a command prompt before or after you start Carbide. For cleanest operation, I do it before I open the IDE.

Change to the SDK directory which contains the emulator and support files, and type the command “epoc” with no arguments. On my system it looks this way:

C: cd \Symbian\9.2\S60_3rd_FP1\Epoc32\winscw

C: epoc

Looking Ahead:

Next time, we’ll toss a couple of breakpoints into HelloWorld and see the emulator in action as a debugging tool.

Talk Back!

Have an opinion? Readers have already posted 1 comment about this weblog entry. Why not add yours?

RSS Feed

If you'd like to be notified whenever Nancy Nicolaisen adds a new entry to her weblog, subscribe to her RSS feed.

About the Blogger

Nancy Nicolaisen has authored three books on C++ programming topics; hundreds of articles for print magazines including Byte, Dr. Dobbs and PC Magazine; and was the chief contributor to codeguru.com's Windows CE Zone. Former researcher and Computer Science Professor, she specializes in small device and embedded systems programming.

This weblog entry is Copyright © 2008 Nancy Nicolaisen. All rights reserved.

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2014 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us