Wiley.Developing.Software.for.Symbian.OS.2nd.Edition.Dec.2007 (779887), страница 13
Текст из файла (страница 13)
Symbian OS does notuse a makefile because:•The system supports many types of build tools (including make programs) and so needs a generic solution with platform independence.•A custom build system can define information specific to Symbian,such as the program UIDs.•IDE tools such as Carbide.c++ have the ability to import MMP files tocreate Symbian application projects.As you will see later, Symbian build tools generate makefiles basedon this MMP file – this is all done behind the scenes from an applicationdeveloper’s viewpoint.The Symbian build system will be discussed in Chapter 5. For thisexample the main thing to note is that it defines what source and resourcefiles should be compiled and what libraries should be used for linking.The locations to search for project-defined and system include files, andsource files and locations, are also defined.TARGET TYPE should always be EXE and the first number underUID should always be 0x100039CE for GUI applications.
The secondnumber under UID identifies the application specifically and shouldalways match the one returned by AppDllUid in the application object(in file SimpleEx app.cpp in this example).The only difference between the platforms in the MMP file is theGUI-specific library for that particular platform. S60 uses avkon.liband UIQ uses qikctl.lib.Creating the bld.inf fileThe file bld.inf points the build tools to the correct project definition(MMP) file. Type this into a file and name it bld.inf in the groupdirectory:PRJ_MMPFILESSimpleEx.mmp2.4 Building and Executing on the EmulatorTo build the application, change directory to the group subdirectory andexecute these commands:c:\...\group> bldmake bldfilesc:\...\group> abld build winscw udebBUILDING AND EXECUTING ON THE EMULATORFigure 2.10S60 3rd Edition ExampleFigure 2.11 UIQ 3 Example5758SYMBIAN OS QUICK STARTMake sure you have the appropriate SDK selected when you enter thesecommands.
This can be done with the devices command as describedin section 2.2.Run the emulator on the PC (for example, by typing epoc at thecommand prompt as described in section 2.2.1) and select the applicationlabeled SimpleEx from the desktop on UIQ or ‘Installed’ folder for S60.Figures 2.10 and 2.11 show how the example looks on the differentsoftware platforms.2.5 A Carbide.c++ ProjectYou can import the SimpleEx program into Carbide.c++ as described atthe end of section 2.2.3.
Once you have the project in Carbide.c++, youcan place breakpoints and step through the code.Figure 2.12 shows the S60 SimpleEx project in Carbide.c++. I set abreakpoint at the beginning of the command handler in the applicationUI class by double-clicking in the gray column at the left of the code line(the dot there indicates that a breakpoint is set).
You can start runningyour program in the debugger by selecting Run->Debug. Then when youhit breakpoints, you can step through your code (the Run menu will giveyou the various options for stepping through the code).Figure 2.12 S60 SimpleEx in Carbide.c++BUILDING FOR THE SMARTPHONE592.6 Building for the SmartphoneTo build for a smartphone target (we are back on the command line now),you’ll need to specify a different build target; ARM (gcce) in release(urel) mode:c:\...\group>abld build gcce urelThis will build an ARM executable suitable for running on your phone.After you’ve built the binary, you need to create an installation filefor installing and running the application on the phone.
Symbian OSprovides a utility called makesis to create the SIS file. You’ll need tocreate a package definition file (PKG file); this defines what goes into theSIS file. The package file specifies various attributes of the installationfile and includes a list of files that belong in the installation. This file listincludes where each program file is found on the host PC (so makesiscan locate them to build them into the SIS file) and where each of thesefiles should be placed on the phone when the SIS is installed. Once wehave a SIS file, we’ll sign this SIS file with a self-created certificate inorder to create what is called a SISX file.
Although it sounds complicated,it isn’t really and, for Symbian OS v9, smartphones typically require theapplications to be signed (more on this in Chapter 7) so you need tofamiliarize yourself with this step early on.Let’s look at the package definition files (PKG files) for S60 3rd Editionand UIQ 3. Type in the one corresponding to your platform, save it asSimpleEx.pkg, and save it in the group directory. The text in boldshould correspond to the location where you installed your SDK.The following shows the S60 package file. The path in bold representsthe default location of the S60 3rd Edition FP1 SDK and should bechanged if you installed your SDK in a location different to the defaultdirectory (c:\Symbian\9.2\S60 3rd FP1).; SimpleEx.pkg for S60 3rd Edition;;Language - standard language definitions&EN; standard SIS file header#{"SimpleEx"},(0xE000027F),1,0,0;Localised Vendor name%{"Vendor"};Supports Series 60 v 3.0[0x101F7961], 0, 0, 0, {"Series60ProductID"};;Files to install"c:\Symbian\9.2\S60_3rd_FP1\epoc32\release\gcce\urel\SimpleEx.exe"-"!:\sys\bin\SimpleEx.exe"60SYMBIAN OS QUICK START"c:\Symbian\9.2\S60_3rd_FP1\epoc32\data\z\resource\apps\SimpleEx.rsc"-"!:\resource\apps\SimpleEx.rsc""c:\Symbian\9.2\S60_3rd_FP1\epoc32\data\z\private\10003a3f\apps\SimpleEx_reg.rsc" -"!:\private\10003a3f\import\apps\SimpleEx_reg.rsc"The UIQ package file is as follows:; SimpleEx.pkg for UIQ 3;;Language - standard language definitions&EN; standard SIS file header#{"SimpleEx"},(0xE000027F),1,0,0;Localised Vendor name%{"Vendor-EN"}; Unique vendor name mandatory for UIQ:"Vendor"; Supports UIQ 3[0x101F6300], 3, 0, 0, {"UIQ30ProductID"};;Files to install"c:\Symbian\UIQ3SDK\epoc32\release\gcce\urel\SimpleEx.exe"-"!:\sys\bin\SimpleEx.exe""c:\Symbian\UIQ3SDK\epoc32\data\z\resource\apps\SimpleEx.rsc"-"!:\resource\apps\SimpleEx.rsc""c:\Symbian\UIQ3SDK\epoc32\data\z\private\10003a3f\apps\SimpleEx_reg.rsc"-"!:\private\10003a3f\import\apps\SimpleEx_reg.rsc"The last few lines of the package file specify the individual files to copyto the phone – the first filename specifying where to find the file on thePC and the second where to place it on the phone.
Further discussion ofthe format of these files can be found in Chapter 5.Next, run the following command at the command prompt:c:\...\group\>makesis SimpleEx.pkgThis command creates the installation file SimpleEx.sis.Although it’s up to the manufacturer, you typically cannot installSymbian OS v9-based applications unless they are digitally signed bya certificate. For this example, we will self-sign the application with acertificate we generate ourselves.Run the following command to create a certificate:c:\...\group\> makekeys -cert -len 2048 -dname "CN=MyName OU=MyCompany"mycert.key mycert.cerYou will be prompted to ask if you want to define a password. Answerno.
You will then be asked to press random keys or move the mouse toBUILDING FOR THE SMARTPHONE61generate some random data, after which you will have your certificatefile (mycert.cer) and an associated private key (mycert.key).To sign your SIS file, enter the following command:c:\...\group\> signsis SimpleEx.sis SimpleEx.sisx mycert.cer mycert.keyThis command will sign your SimpleEx.sis with your newly createdcertificate files.
The signed copy is output as SimpleEx.sisx.Install SimpleEx.sisx to your smartphone through your PC suite(or any method your smartphone has of installing an application SIS file).The SIS file is the standard file for users to install applications to theirsmartphones, and the installation process should be well documented inthe smartphone’s user manual. The .sisx suffix indicates a signed SISfile.Because this application is not signed by a certificate that is certifiedand signed by a trusted CA, you will get a message indicating thatthe application is from a non-trusted source – ignore this and continueinstalling the application.Once you load the program on the smartphone you can run it as youdid from the emulator by locating it by name in the main menu andopening it.