Symbian OS C ++ Learning

Source: Internet
Author: User
Original Web site: http://www.hotpim.com/blog/myIndex.jsp? A = BC & B = 2130 & U = 387

Symbian OS c ++ has been learning Symbian mobile phone development for nearly two weeks. I personally think it is really difficult to get started with Symbian, and many detours have been taken in the process of learning Symbian development, now I will write down the process of learning Symbian in this period, hoping to bring some help to colleagues who intend to learn Symbian development in the future. As the saying goes, to do something better, you must first sharpen the tool, to learn about Symbian mobile phone development, you must first install the Symbian Development Environment (Here we use Symbian SDK 2.0 and vc6 IDE). I will not introduce it in detail here. For more information, see the Symbian Installation Guide, install Symbian in sequence and check whether it can be used by copying helloworld (C: \ Symbian \ 7.0s \ series60_v20 \ examples \ helloworld) in the installation directory) sample to the system root directory (C root directory), then enter the doscommand interface, enter the current helloworld directory, enter bldmake bldfiles (such as 1) and press Enter. If the installed Symbian development environment is unavailable, an error will be prompted, and the normal situation will not be prompted (for example, 1); Figure 1 tips: I don't know why. I found out when I learned Symbian, if the project file to be compiled is not stored on drive C, enter bldmake bldfiles to prompt that the environment variable rpocroot is faulty and other compilation commands will cause problems (In addition, create a project in VC, if it is not on the C drive, it will also be a problem). The specific cause is not clear yet (maybe Symbian hard rules). Therefore, I suggest placing the project on the C drive, in this way, we can develop smoothly. Now, the development environment has been established. Next we will introduce how to learn Symbian OS c ++. I suggest you do not buy any reference books for beginners, you can directly view the built-in documentation in the SDK. the SDK documentation (directly go to the C: \ Symbian \ 7.0s \ series60_v20 \ series60doc directory) has a detailed introduction to Symbian. Of course, these documents are all in English. If the English is not very good, it is really difficult to learn. But I think it is not a big deal to drive Kingsoft, and then read it with a hard head, it takes more time to learn Symbian and improve English; 1 Read SDK DocumentI think we should first look at coding idioms for Symbian ossag. This document mainly describes some popular Symbian Development conventions. The reason is that when you are familiar with these conventions, next, let's look at the examples or other documents. It's not surprising, because Symbian C ++ is very different from the C ++ programming specifications on our normal PC platform. I took a detour in the learning process, I got a book called "Symbian OS c ++ mobile app development" at the beginning of my study. I was confused at the beginning because I didn't understand the Symbian programming conventions, so we can see that many names and Code do not know what is going on; then, let's look at Series 60 UI style guide.pdf, this document mainly introduces some basic UI patterns and terminology of Series 60 development. Of course, if you have previously worked on mobile phone development, you may not want to read it, at present, most mobile phones have almost the same interface pattern. Next, let's look at the documents getting startedlinks, Guide for application developers on document handler.pdf and Appwizard guide.pdf, the first two documents mainly give you a perceptual knowledge of Symbian development and some basic knowledge. The last one is to teach you how to use VC ide to build a new Symbian project; with the basic knowledge above, let's look at the application framework handbook.pdf document. This document is very important. It mainly introduces the development framework of Symbian software programs (professionally speaking, it is the software design model ), after reading this document, you should have an overall understanding of the Symbian Software Development Framework (a lot of other knowledge is required for real development) and how to build a Symbian application, you should be aware of the specific steps for writing Symbian programs. Here, I will mention the design pattern used by Symbian. It adopts the MVC pattern. MVC literally means model, view, and control, model is mainly responsible for data, view is mainly used to display data and some screen processing, control is mainly responsible for processing user interaction and data access control; MVC is very similar to Microsoft's document/view structure (people with Microsoft's MFC programming experience should be very clear). The purpose of using MVC is mainly to clear the file structure, the complexity of software development is significantly reduced. After reading the above documents, you should have a basic understanding of Symbian and the overall development framework. Next, you can take a look at the in-depth development materials, as for the order, it does not matter. You can do it yourself and read other materials; 2 , Sample analysisTo learn how to develop Symbian, it is useless to read data. You have to read the sample code and write your own code. Next, let's analyze the helloworld program: helloworld. this file is a project file and indicates that the project contains the following information: target file name, target problem type, UID (Application ID number, location of the target file, resource file, source file, header file, and library file; helloworld. the RSS resource file defines the resources used by the Program (including character resources, menus, and other resources); helloworld. UID. CPP, which defines the program identification number. helloworld_main.cpp is the file where the program entry point is located. This file contains two functions, tint e32dll (tdllreason) and capaapplication * newapplication (). The previous one has no significance, the next one is used to create a program example, which is the entry point of the entire program. The whole program is used to create the first application object instance. Here we create a cexampleapplic An instance of the ation object; the specific implementation file of the helloworld_application.cpp and cexampleapplication class object contains two functions: createdocumentl () and appdlluid (). The previous one is used to create a document object instance, the next one gets the program id; The implementation file of the helloworld_document.cpp and cexampledocument Class Object, including the cexampledocument (ceikapplication & AAPP) and createappuil () member functions. The first one is the constructor, the next one is used to create the application interface object; the implementation file of helloworld_appui.cpp, cexampleappui class object, and the handlecommandl (tint acommand) command processing function ,~ Cexampleappui () destructor, constructl () Stage 2 constructor, used to create an application view; helloworld_appview.cpp, the default constructor cexampleappview () in this file, constructl (const trect & arect) Stage 2 constructor to create a specific view interface ,~ Cexampleappview () destructor, newl (const trect & arect) object example build function, draw (const trect &/* arect */) View window draw function, used to draw a window; the entire program creation process is: the system creates a cexampleapplication object instance through newapplication, and then creates a cexampledocument object by cexampledocument. Finally, the cexampleappview object is created by cexampleappui; from the MVC perspective, cexampledocument corresponds to M, cexampleappui corresponds to C, cexampleappview corresponds to V; therefore, the entire file contains four parts, that is, four classes, application class, document class, application UI class, and application View class; 3 , Application CompilationThere are two ways to compile an application: command line performance and graph ide compilation. I personally prefer command line compilation. First, go to the directory where the helloworld compilation configuration file is located (generally bld. INF file directory. Here is the current helloworld directory), then enter bldmake bldfiles (1), and then enter abld build wins udeb (here we will explain the two parameters wins and udeb, the previous parameter is specified to be generated for the simulator and the VC compiler. The latter parameter indicates Unicode debugging and generation. This completes the compilation; if you want to open the project in vc ide, run the command abld makefile vc6 to open the VC project file in the future; 4 , Run the programTo run the compiled program, you can directly input epoc.exe in the command line or click Run in vc ide (you need to select EPOC to run, in c: \ Symbian \ 7.0s \ series60_v20 \ epoc32 \ release \ WINS \ udeb ), in this way, after the simulator is started, the compiled program can be run on the simulator. The above is only compiled into a debugging program that can be run on the simulator. The real program will run on the real machine, then, you need to modify the compilation parameters, create the installation package, and install the package on the real machine. To sum up, compile the command bldmake bldfiles: generate the project file and the batch file abld. BAT; abld build <platform> <buildtype>: Compile command. If the <buildtype> parameter is udeb, a debug version is generated. If it is urel, the release version is all, two types are generated at the same time. <platform> depends on the target processor and the used compiler. If it is under the simulator, there are winsb (for Borland C ++) and winscw (metrowerks) wins (Microsoft) uses the same process. It can be generated by running commands on the actual target mobile phone, but the <platform> parameter is different. It can be arm4 (compiled for armv4 instruction set ), armi (compiled for the thumb mode subset of the armv4t Instruction Set), and thumb (compiled for the arm mode subset of the armvt Instruction Set). To use vc6 IDE, enter include abld. in the directory of the BAT file, enter abld makefile vc6 in the command line.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.