Wiley.Developing.Software.for.Symbian.OS.2nd.Edition.Dec.2007 (779887), страница 9
Текст из файла (страница 9)
Take a look at the variousoptions to run Windows on your Mac, depending on your hardware, suchas Apple’s Boot Camp or Parallels Desktop for Mac.2.2 Firing Up the Development ToolsAt this point, you should have your SDK and compatible Windowsdevelopment tool set installed. Now it’s time to test your setup andcompile some example code.Here’s a tip if you have multiple SDKs installed and the SDK you areusing is based on Symbian OS v7.0 or later.
At the command prompt, type:devicesto list your installed SDKs. Locate the SDK you want to use and ensure ithas ‘default’ displayed next to it. If it does not, then enter:devices -setdefault @<sdk name>where the SDK name is exactly as it appears on the devices line.Figure 2.3 shows an example of switching from the Series 60 3rdEdition FP1 SDK to the UIQ 3 SDK.Switching to the correct SDK via the devices command is crucial forcommand line builds, although if you are using an IDE, this switching isautomatic.2.2.1 Quick Test of the EmulatorType epoc from a command prompt. This should bring up the SymbianOS emulator for the supported smartphone type.
The emulator displaysa smartphone desktop where you can select and run various built-in32SYMBIAN OS QUICK STARTprograms and setup utilities. If the emulator does not start, or locks atsome point, then you have a problem with your installation.An example of such a problem is provided by the earlier S60 SDKs,which had a problem when you installed the SDK in a location otherthan the default. The default installation path was hardcoded in theepoc.ini emulator configuration file and caused the emulator not torun if your SDK was located in a different directory. To fix this problem,you would need to manually edit the path contained in epoc.ini,located in the installation directory of the SDK, in the \epoc32\datasubdirectory.Figure 2.3 Using the devices-setdefault Command2.2.2 Quick Test Drive of Carbide.c++The simplest way of testing out Carbide.c++, and to get a feel for itsoperation, is to generate a simple hello world application using its projectwizard, and then build it and see the application run on the emulator.The steps to do this are as follows:1.Once Carbide.c++ is running, choose File->New->Project.2.You will be prompted for a wizard.
Choose either S60 or UIQ underSymbian OS depending on which SDK you have loaded. Select Next.3.Enter a project name and select Next, as shown in Figure 2.4.4.Select a template also depending on which SDK you have, as shownin Figure 2.5.For S60, you can select S60 3.x Application which is a hello worldtemplate for S60 3rd Edition.FIRING UP THE DEVELOPMENT TOOLSFigure 2.4New Project CreationFigure 2.5 Application Template Selection3334SYMBIAN OS QUICK START5.Select Next. The Symbian OS SDK applicable to your previous choiceis displayed, as shown in Figure 2.6.If you do not have the proper SDK, you will be notified here. SelectFinish to take you to defaults for the rest.
This will generate theproject.6.Select Run->Run to build the project and start the emulator so youcan run it.7.When the emulator comes up, go to the main screen or a subfoldersuch as in the S60 3rd Edition, where the installation folder theapplication is put into is ‘Installation’. Click on this icon to run thehello world program within the emulated environment.Figure 2.6 SDK Selection2.2.3 Build Some ExamplesThe SDKs include example projects with source code to help you getfamiliar with Symbian OS.
It’s a good idea to build and run some of theseto test out, and get familiar with, the SDK.In the next few pages, I’ll run through compiling and executingexamples for the emulator, platform by platform from the command line.FIRING UP THE DEVELOPMENT TOOLS35Although you likely will be using Carbide.c++ to build Symbian OS code,it’s also a good idea to get familiar with building on the command line. I’llthen provide some steps for building the examples within Carbide.c++.Building a S60 exampleGo to the S60 example directory from a command prompt. For S60 3rdEdition SDKs, it’s located at Symbian Base\S60Ex, where SymbianBase is your SDK installation directory for S60. It’s at Symbian Base\Series60Ex for S60 versions before 3rd Edition.
I’ll assume you haveinstalled the SDK in the default location. Table 2.1 shows the defaultdirectories for S60 SDKs.Thus, for S60 3rd Edition FP1, type:C:\>cd \Symbian\9.2\S60_3rd\S60Exor for 2nd Edition:C:\>cd \Symbian\7.0s\Series60_v2.0\Series60ExType dir and you will see a list of folders containing examples. Changedirectory to HelloWorldBasic\group to build the hello world program (it’s called HelloWorld in S60 v1.0):C:\Symbian\...\Series60Ex>cd helloworldbasic\groupType the following at the command prompt:C:\...\HelloWorld\group>bldmake bldfilesC:\...\HelloWorld\group>abld build winscw udebTable 2.1 Default SDK Directories for S60SDKDefault Installation DirectoryS60 3rd Edition FP1c:\Symbian\9.2\S60 3rd FP1S60 3rd Editionc:\Symbian\9.2\S60 3rdS60 2nd Editionc:\Symbian\7.0s\Series60 v2.0S60 1st Editionc:\Symbian\6.1\Series6036SYMBIAN OS QUICK STARTThis will build the example and place the output such that it will run inthe Windows emulator.Note, if you are using the Borland or Microsoft tools then you needto specify a target of winsb or wins instead of winscw when runningthe abld command from the command line.
wins, winsb, and winscw indicate emulator builds for Microsoft, Borland, and Carbide.c++development tools, respectively. winscw is also used for CodeWarrior.udeb indicates that it is a debug as opposed to a release build (urel),which means you will have symbols in the code so you can use the IDEdebugger.
With newer SDKs, the release builds are no longer supportedon the emulator.It’s worth pointing out that Borland C++ Builder X can use wins,if configured in Microsoft binary mode. The Borland tool also supportsMetrowerks builds, provided you have a Metrowerks license.To see the program executed on the emulator, at the commandprompt, type:C:\...\HelloWorld\group> epocYou should see the S60 emulator as described in section 2.2.1.
Find yourHelloWorld icon (in the folder labeled Installed or Other, or the maindesktop depending on the SDK) and select it.Building a UIQ exampleGo to the UIQ example directory from a command prompt. This directoryis located at Symbian Base\Examples\UIQ for UIQ version 3.
ForUIQ2, it is at Symbian Base\UIQExamples. Symbian Base is yourSDK installation directory (e.g., c:\Symbian\UIQ3SDK for UIQ 3, andc:\Symbian\UIQ 21 for UIQ 2.1).To build the hello world example in UIQ 3:C:\>cd \Symbian\UIQ3SDK\Examples\UIQType dir and you will see a list of folders containing examples. Changedirectory to QHelloWorld to build the hello world program:C:\Symbian\UIQ3SDK\Examples\UIQ>cd QHelloWorldC:\Symbian\UIQ3SDK\Examples\QHelloWorld>To compile the sample, type the following at the command prompt:C:\Symbian\UIQ3SDK\Examples\QHelloWorld> bldmake bldfilesC:\Symbian\UIQ3SDK\Examples\QHelloWorld> abld build winscw udebFIRING UP THE DEVELOPMENT TOOLS37After the compilation completes, type epoc to start the emulator and runthe application by selecting the HelloWorld icon from the desktop.In the preceding sections, I mentioned that the last argument of theabld command depends on the Windows-based tool kit you are using.Why is there a different target platform indicator (i.e., wins, winscw,winsb) for each tool set? The reason is that abld generates and invokesmakefiles that in turn build your program.
So abld needs to know thetarget platform to determine what tool set to use. For example, when youspecify wins in the abld command, abld creates a Microsoft nmakestyle makefile that contains calls to Microsoft tools (such as cl for thecompiler). The target platform also specifies what set of libraries to linkto since there is a separate set of binary system libraries for each targetplatform. This will be discussed further in Chapter 5.Building examples using Carbide.c++The previous sections described how to build the examples from the command line. You can also build and run the examples using Carbide.c++by importing them into the IDE.
Here is how:1. Start Carbide.c++.2. Select File->Import. Select Symbian bld.inf as the import sourceand then click on Next, as shown in Figure 2.7.3. The next screen will prompt for the location of the bld.inf file.Browse to the project directory where the bld.inf file is located andselect it (e.g., c:\Symbian\UIQ3SDK\Examples\UIQ\QHelloWorld\Group\bld.inf), and then click on Next.4. The bld.inf will then be parsed and the status should be ‘Parsedsuccessfully’. Click on Next.5.
Select the SDK and build configurations and check the ‘All SDKs’box so you can build for emulator and devices. Click on Finish whendone.6. You should now have the example project in Carbide.c++. SelectRun->Run to compile and run in the emulator.Library freezingSometimes, you may get errors when compiling examples that uselibraries. If you get an error indicating that a library is missing, it’snormally because the library could not be built due to it not being frozen.Library freezing will be explained in detail in Chapter 5. For now, if youget that error, type abld freeze winscw (or substitute winscw with thebuild target for whatever platform you are using), then reissue the abld38SYMBIAN OS QUICK STARTFigure 2.7Import from Symbian bld.inf Filebuild command.
Or it could be that the library has not yet been builtat all – some SDKs require you to go to the individual library directoriesand build them before building the main program.2.3 Simple Example ApplicationThis section walks through a simple example of a Symbian OS GUIapplication, from source code to execution. The example is presented forboth S60 3rd Edition and UIQ 3 smartphones.Although you could download this example from the book’s website,you may want to actually type in the code in order to get a good feel forthe core classes.