Difference between revisions of "SymbianOS"

From Lazarus wiki
Jump to navigationJump to search
m (Added warning that Symbian port was abandoned; fixed syntax highlighting)
(26 intermediate revisions by 4 users not shown)
Line 1: Line 1:
The SymbianOS port of Free Pascal is under construction.
+
{{Warning|The work was too large, the platform changed too fast and now the entire SymbianOS is deprecated, so the port was abandoned}}
  
 
==Roadmap to port FPC to SymbianOS==
 
==Roadmap to port FPC to SymbianOS==
  
# <strike>Develop a Hello World application on c++ for SymbianOS</strike> - Felipe
+
# <strike>Develop a Hello World application on c++ for SymbianOS UIQ 3</strike> - Felipe
 
# <strike>Convert the Build software from perl to our own building system, and make it build the c++ software</strike> - Felipe
 
# <strike>Convert the Build software from perl to our own building system, and make it build the c++ software</strike> - Felipe
 
# <strike>Effectively start to port the Free Pascal Runtime Library</strike> - Felipe
 
# <strike>Effectively start to port the Free Pascal Runtime Library</strike> - Felipe
 
# Convert some c++ symbian applications to check for errors on the port - Felipe - 1 trivial done, more to go
 
# Convert some c++ symbian applications to check for errors on the port - Felipe - 1 trivial done, more to go
 +
# Complete the port of Free Pascal Runtime Library
 +
# Start developing with UIQ 2 SDK, and make adjustments for everything to work with it
 +
# Make sure everything works on the real Phone with UIQ 2 too
  
 
==Versions Roadmap==
 
==Versions Roadmap==
  
 
The first target will be UIQ 3.0 for the Symbian OS on x86 architecture (the emulator).
 
The first target will be UIQ 3.0 for the Symbian OS on x86 architecture (the emulator).
 +
 +
Next will be the UIQ 2 for x86 emulator, and last the UIQ 2 real device.
  
 
==Compiling Free Pascal for the Emulator==
 
==Compiling Free Pascal for the Emulator==
Line 16: Line 21:
 
1 - Download the latest FPC from Subversion. Make sure you also have the latest stable FPC installed.
 
1 - Download the latest FPC from Subversion. Make sure you also have the latest stable FPC installed.
  
2 - Next you will need a assembler compatible with the Code Warrior linker. Currently this is the GNU Assembler. It´s a good coincidence that the emulator users normal win32 PE executables, but of course it could use any other format, so FPC will expect a cross-assembler with the correct name. Because of this we can simply copy the as.exe file that comes with FPC releases and rename it.
+
2 - Next you will need a assembler compatible with the Code Warrior linker. Currently this is the GNU Assembler. It´s a good coincidence that the emulator uses normal win32 PE executables, but of course it could use any other format, so FPC will expect a cross-assembler with the correct name. Because of this we can simply copy the as.exe file that comes with FPC releases and rename it.
  
 
Suppose your win32 gnu assembler is located at: C:\Programas\lazarus20\fpc\2.0.4\bin\i386-win32\as.exe
 
Suppose your win32 gnu assembler is located at: C:\Programas\lazarus20\fpc\2.0.4\bin\i386-win32\as.exe
Line 37: Line 42:
 
4 - Building the RTL only is not enougth to compile a Symbian OS application. We also need the c++ bindings which connect our RTL to the Symbian libraries.
 
4 - Building the RTL only is not enougth to compile a Symbian OS application. We also need the c++ bindings which connect our RTL to the Symbian libraries.
  
4.1 - To build the bindings you will need the helper application called mksymbian. Please download it with subversion using this command:
+
4.1 - To build the bindings you will need the helper application called mksymbian. This application is included with the Free Pascal sources on the directory utils/mksymbian
  
svn co https://p-tools.svn.sourceforge.net/svnroot/p-tools/mksymbian mksymbian
+
4.2 - Next compile mksymbian. There is a lazarus project to help building it, but directly calling the compiler from command line works just as well, like this:
  
4.2 - Next compile mksymbian. There is a lazarus project to help building it, but directly calling the compiler from command line should work just as well.
+
fpc mksymbian.pas
  
 
4.3 - Copy the mksymbian executable to the fpc/rtl/symbian/bindings directory, open a console, go to the fpc/rtl/symbian/bindings directory and type this command:
 
4.3 - Copy the mksymbian executable to the fpc/rtl/symbian/bindings directory, open a console, go to the fpc/rtl/symbian/bindings directory and type this command:
Line 47: Line 52:
 
  mksymbian bindings
 
  mksymbian bindings
  
4.4 - Copy the resulting .o file(s) to where your symbian os RTL is located. On our example it´s on: C:\Programas\fpc21\rtl\units\i386-symbian
+
The resulting .o file(s) will be located on: C:\Programas\fpc21\rtl\units\i386-symbian
  
5 - Next you can go to the session "Building Symbian OS Applications" bellow, to learn how to use your compiler to generate a Object Pascal software for Symbian.
+
5 - Next you can go to the session "Building Symbian OS Applications" below, to learn how to use your compiler to generate a Object Pascal software for Symbian.
  
 
The Symbian OS RTL will be located at: C:\Programas\fpc21\rtl\units\i386-symbian
 
The Symbian OS RTL will be located at: C:\Programas\fpc21\rtl\units\i386-symbian
Line 60: Line 65:
 
==Building Symbian OS Applications==
 
==Building Symbian OS Applications==
  
This section is a documentation on the attempt to re-engineer the UIQ 3 build system to a format more friendly to Free Pascal and cross-platform development in general.
+
===Overview===
  
===Default SDK Build Process===
+
Building an application on Symbian OS requires some learning, because there are several unique things about Symbian which must be utilized even the most simple applications. For example the UIDs, the need to register a application on the Emulator, etc.
  
Two commands are executed when building UIQ 3 software for the emulator. Suppose your UIQ SDK is installed on c:\Symbian\UIQ3SDK and your software C++ source code is on C:\QHelloWorld\src.
+
The UIQ SDK has a very complex build system composed of several ten thousends lines of Perl code, batch files and Makefiles. It induces the software to have a specific directory structure, which is very bad to port existing software, as well as to write cross-platform software. Because cross-platform is a strong point on Free Pascal, we decided to simplify and improve the process when writing our build system for Symbian. We created a external build utility, called mksymbian, written in Pascal that auxiliates the build process.
  
On C++ you should enter the directory C:\QHelloWorld\group where the build file is located (bld.inf), and type:
+
===Guide for building applications for the Emulator===
 +
 
 +
You need first to write a .ini file that will contain Symbian OS specific information. Here is a example file called QPasHello.ini
  
 
<pre>
 
<pre>
bldmake bldfiles
+
[Main]
abld build winscw udeb
+
EXENAME=QPasHello.exe
</pre>
+
Language=Pascal
 +
ProjectType=EXE
 +
SDK=UIQ
 +
SDKVersion=3
 +
Emulator=1
  
The first command will:
+
[FPC]
 +
CompilerPath=C:\Programas\fpc21\compiler\ppc386.exe
 +
AssemblerPath=C:\Programas\lazarus215\fpc\2.1.5\bin\i386-win32\as.exe
 +
RTLUnitsDir=C:\Programas\fpc21\rtl\units\i386-symbian\
  
* Generate the directory: C:\Symbian\UIQ3SDK\epoc32\BUILD\Programas\SymbianOS\QHelloWorld\group
+
[UIDs]
 +
UID2=0x100039CE
 +
UID3=0xE1000002
  
*Fill it with many Makefiles
+
[Files]
 +
mainsource=QPasHello.pas
 +
mainresource=QPasHello_reg.rss
  
*Create a ABLD.BAT script
+
[Objects]
 +
file0=qpashello.o
 +
</pre>
  
*Perl files involved: bldmake.pl
+
And the respective QPasHello.pas source file:
  
The second command will:
+
<syntaxhighlight lang="pascal">
 +
{
 +
QPasHello.pas
  
*Generate the directory: C:\Symbian\UIQ3SDK\epoc32\BUILD\Programas\SymbianOS\QHelloWorld\group\QHELLOWORLD\WINSCW
+
*****************************************************************************
 +
*                                                                          *
 +
*  This demonstration program is public domain, which means no copyright,  *
 +
* but also no warranty!                                                    *
 +
*                                                                          *
 +
*  This program is distributed in the hope that it will be useful,          *
 +
*  but WITHOUT ANY WARRANTY; without even the implied warranty of          *
 +
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                    *
 +
*                                                                          *
 +
*****************************************************************************
  
*There it will put the source code, a QHELLOWORLD.WINSCW file and a UDEB directory with compiled .o files for the software
+
This application will create a popup message 'My Hello World' and then quit
  
*It will also create a executable (QHelloWorld.exe) for the software on the directory: C:\Symbian\UIQ3SDK\epoc32\release\winscw\udeb
+
The message will last a few seconds.
  
*Perl files involved: abld.pl makmake.pl
+
Author: Felipe Monteiro de Carvalho
 +
}
 +
program QPasHello;
  
===Modifyed Build Process===
+
uses symbian;
  
To aid on this complex build process, a command line tool called "mksymbian" will be created.
+
begin
 +
  User_InfoPrint('My Hello World');
 +
end.
 +
</syntaxhighlight>
  
Default UIQ build process expects that the source be on a rather peculiar directory format. This is unsuitable for cross-platform development. Just imagine if each OS required a different directory tree, cross-platform would be impossible. Instead we will change this to simply require that the project be the only project on it´s directory. This is already required by many tools, like make, so it should be a flexible enougth restriction for cross-platform.
+
And also the main resource file QPasHello_reg.rss:
  
On the folder of the project you should have source code and also a project information file. This file is in INI format, and specifies many information for our tool to use to build the project. The file must be called "mksymbian.ini"
+
<pre>
 +
// QHelloWorld_reg.rss
 +
#include <AppInfo.rh>
 +
UID2 0x100039CE
 +
UID3 0xE1000002
 +
RESOURCE APP_REGISTRATION_INFO
 +
{
 +
  // filename of app binary (minus extension)
 +
  app_file = "QPasHello";
 +
}
 +
</pre>
  
To compile a C++ project with it you can do:
+
Next use mksymbian to build your application, like this:
  
mksymbian cpp
+
mksymbian build QPasHello.ini
  
This is just utilized to show that the tool produces correct output, as our objetive here is to build Object Pascal software.
+
If something goes wrong, check if mksymbian located your directories correctly:
  
One important task of this build tool is identifying correctly where Symbian SDKs and Free Pascal are installed.
+
mksymbian showpath
 +
 
 +
Also make sure to correct the paths according to your system on the ini file.
  
 
===Using mksymbian===
 
===Using mksymbian===
  
The sintax of this tool is:
+
The syntax of this tool is:
  
 
mksymbian [action] [project file]
 
mksymbian [action] [project file]
  
 
Action can be one of the following:
 
Action can be one of the following:
 
+
* build - Compiles a project
* cpp - Compiles a C++ project
 
* pascal - Compiles a Object Pascal project
 
 
* bindings - Compiles the pascal bindings for Symbian OS. It supposes that the necessary files are on the location where the command is executed.
 
* bindings - Compiles the pascal bindings for Symbian OS. It supposes that the necessary files are on the location where the command is executed.
 
* showpath - Shows the paths found for the Symbian SDKs and Free Pascal. Utilized to check if the tool was able to find the tools.
 
* showpath - Shows the paths found for the Symbian SDKs and Free Pascal. Utilized to check if the tool was able to find the tools.
Line 130: Line 176:
  
 
Note: The tool parameters are not case-sensitive
 
Note: The tool parameters are not case-sensitive
 
===Registering a application on the UIQ Emulator===
 
 
Each application should provide a non-localizable resource file with information necessary to register it on the emulator (or later on a real phone). This file ends with the .rss extension and should look similar to this example one:
 
 
<pre>
 
// QHelloWorld_reg.rss
 
#include <AppInfo.rh>
 
 
UID2 KUidAppRegistrationResourceFile
 
UID3 0x01000001
 
 
RESOURCE APP_REGISTRATION_INFO
 
{
 
// filename of application binary (minus extension)
 
app_file = "QHelloWorld";
 
}
 
</pre>
 
 
During the build process this file will be compiled into a .RCS resource file. On the emulator, all registration files should be located on the directory \private\10003a3f\apps
 
 
Mksymbian tool will take care of compiling the resource and placing it on the correct position. There next paragraphs on this sections are technical details of how this is done.
 
 
Looking at the UIQ 3 SDK directory structure you will find 3 directories that match \private\10003a3f:
 
 
* C:\Programas\UIQ3SDK\epoc32\data\Z\private\10003a3f\apps
 
 
Here a copy of your RCS resource file will be put
 
 
* C:\Programas\UIQ3SDK\epoc32\winscw\c\Private\10003a3f
 
 
This directory contains only some binary files.
 
 
* C:\Programas\UIQ3SDK\epoc32\release\winscw\udeb\Z\private\10003a3f\apps
 
 
Here a copy of your RCS resource file will be put, and you can also see RCS files for all other software installed on the emulator.
 
  
 
==Screenshots==
 
==Screenshots==
  
First pascal symbian os application:
+
First pascal symbian os UIQ 3 application:
  
 
[[Image:First_pascal_symbian_app.PNG]]
 
[[Image:First_pascal_symbian_app.PNG]]
Line 175: Line 185:
 
==See Also==
 
==See Also==
  
 +
*[[Programming in Symbian OS]]
 
*[[Symbian OS Internals]]
 
*[[Symbian OS Internals]]
  
Line 180: Line 191:
  
 
* http://developer.uiq.com/ - UIQ version 3 and superior developer community, with SDK download, Forum, Documentation and News.
 
* http://developer.uiq.com/ - UIQ version 3 and superior developer community, with SDK download, Forum, Documentation and News.
* http://www.symbian.com/developer/techlib/v70sdocs/doc_source/reference/cpp/libc/index.html  docs for the POSIX layer  
+
* [http://www.symbian.com/developer/techlib/v70sdocs/doc_source/reference/cpp/libc/index.html] docs for the POSIX layer  
* http://www.symbian.com/developer/techlib/v70sdocs/doc_source/devguides/cpp/base/CStandardLibrary/DesignSTDLIB.html  a bit of description for the POSIX layer
+
* [http://www.symbian.com/developer/techlib/v70sdocs/doc_source/devguides/cpp/base/CStandardLibrary/DesignSTDLIB.html] a bit of description for the POSIX layer
* compiling perl for symbian http://search.cpan.org/~rgarcia/perl-5.9.4/README.symbian they mainly use the POSIX libraries...
+
* [http://search.cpan.org/~rgarcia/perl-5.9.4/README.symbian] - Compiling perl for symbian. They mainly use the POSIX libraries...
 +
* [https://developer.uiq.com/forum/entry.jspa?externalID=31] - List of the UIQ Phones and the UIQ SDK version to use.
 +
* [https://developer.uiq.com/forum/kbclick.jspa?categoryID=21&externalID=26&searchID=101700] - APIs changed from UIQ 2.1 to UIQ 3
 +
* [https://developer.uiq.com/forum/kbclick.jspa?categoryID=21&externalID=20&searchID=101700] - How to port my application from UIQ 2.x to UIQ 3
 +
 
 +
[[Category:Symbian]]
 +
[[Category:Mobile]]
 +
[[Category:Historical]]

Revision as of 11:02, 19 August 2019

Warning-icon.png

Warning: The work was too large, the platform changed too fast and now the entire SymbianOS is deprecated, so the port was abandoned

Roadmap to port FPC to SymbianOS

  1. Develop a Hello World application on c++ for SymbianOS UIQ 3 - Felipe
  2. Convert the Build software from perl to our own building system, and make it build the c++ software - Felipe
  3. Effectively start to port the Free Pascal Runtime Library - Felipe
  4. Convert some c++ symbian applications to check for errors on the port - Felipe - 1 trivial done, more to go
  5. Complete the port of Free Pascal Runtime Library
  6. Start developing with UIQ 2 SDK, and make adjustments for everything to work with it
  7. Make sure everything works on the real Phone with UIQ 2 too

Versions Roadmap

The first target will be UIQ 3.0 for the Symbian OS on x86 architecture (the emulator).

Next will be the UIQ 2 for x86 emulator, and last the UIQ 2 real device.

Compiling Free Pascal for the Emulator

1 - Download the latest FPC from Subversion. Make sure you also have the latest stable FPC installed.

2 - Next you will need a assembler compatible with the Code Warrior linker. Currently this is the GNU Assembler. It´s a good coincidence that the emulator uses normal win32 PE executables, but of course it could use any other format, so FPC will expect a cross-assembler with the correct name. Because of this we can simply copy the as.exe file that comes with FPC releases and rename it.

Suppose your win32 gnu assembler is located at: C:\Programas\lazarus20\fpc\2.0.4\bin\i386-win32\as.exe

You should make a copy of it with this name: C:\Programas\lazarus20\fpc\2.0.4\bin\i386-win32\i386-symbian-as.exe

3 - Now, open a Windows Command Line session. The following batch script will execute a full compilation of FPC for the emulator. In this particular case lazarus was installed on C:\Programas\lazarus20 and the fpc 2.1 source code is on C:\Programas\fpc21

PATH=C:\Programas\lazarus20\fpc\2.0.4\bin\i386-win32
cd c:\Programas\fpc21
cd compiler
make i386
cd ..
cd rtl
cd symbian
make FPC=C:\Programas\fpc21\compiler\ppc386.exe

4 - Building the RTL only is not enougth to compile a Symbian OS application. We also need the c++ bindings which connect our RTL to the Symbian libraries.

4.1 - To build the bindings you will need the helper application called mksymbian. This application is included with the Free Pascal sources on the directory utils/mksymbian

4.2 - Next compile mksymbian. There is a lazarus project to help building it, but directly calling the compiler from command line works just as well, like this:

fpc mksymbian.pas

4.3 - Copy the mksymbian executable to the fpc/rtl/symbian/bindings directory, open a console, go to the fpc/rtl/symbian/bindings directory and type this command:

mksymbian bindings

The resulting .o file(s) will be located on: C:\Programas\fpc21\rtl\units\i386-symbian

5 - Next you can go to the session "Building Symbian OS Applications" below, to learn how to use your compiler to generate a Object Pascal software for Symbian.

The Symbian OS RTL will be located at: C:\Programas\fpc21\rtl\units\i386-symbian

Compiling Free Pascal for the real device

Not yet implemented.


Building Symbian OS Applications

Overview

Building an application on Symbian OS requires some learning, because there are several unique things about Symbian which must be utilized even the most simple applications. For example the UIDs, the need to register a application on the Emulator, etc.

The UIQ SDK has a very complex build system composed of several ten thousends lines of Perl code, batch files and Makefiles. It induces the software to have a specific directory structure, which is very bad to port existing software, as well as to write cross-platform software. Because cross-platform is a strong point on Free Pascal, we decided to simplify and improve the process when writing our build system for Symbian. We created a external build utility, called mksymbian, written in Pascal that auxiliates the build process.

Guide for building applications for the Emulator

You need first to write a .ini file that will contain Symbian OS specific information. Here is a example file called QPasHello.ini

[Main]
EXENAME=QPasHello.exe
Language=Pascal
ProjectType=EXE
SDK=UIQ
SDKVersion=3
Emulator=1

[FPC]
CompilerPath=C:\Programas\fpc21\compiler\ppc386.exe
AssemblerPath=C:\Programas\lazarus215\fpc\2.1.5\bin\i386-win32\as.exe
RTLUnitsDir=C:\Programas\fpc21\rtl\units\i386-symbian\

[UIDs]
UID2=0x100039CE
UID3=0xE1000002

[Files]
mainsource=QPasHello.pas
mainresource=QPasHello_reg.rss

[Objects]
file0=qpashello.o

And the respective QPasHello.pas source file:

{
 QPasHello.pas

 *****************************************************************************
 *                                                                           *
 *  This demonstration program is public domain, which means no copyright,   *
 * but also no warranty!                                                     *
 *                                                                           *
 *  This program is distributed in the hope that it will be useful,          *
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of           *
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                     *
 *                                                                           *
 *****************************************************************************

 This application will create a popup message 'My Hello World' and then quit

 The message will last a few seconds.

 Author: Felipe Monteiro de Carvalho
}
program QPasHello;

uses symbian;

begin
  User_InfoPrint('My Hello World');
end.

And also the main resource file QPasHello_reg.rss:

// QHelloWorld_reg.rss
#include <AppInfo.rh>
UID2 0x100039CE
UID3 0xE1000002
RESOURCE APP_REGISTRATION_INFO
{
  // filename of app binary (minus extension)
  app_file = "QPasHello";
}

Next use mksymbian to build your application, like this:

mksymbian build QPasHello.ini

If something goes wrong, check if mksymbian located your directories correctly:

mksymbian showpath

Also make sure to correct the paths according to your system on the ini file.

Using mksymbian

The syntax of this tool is:

mksymbian [action] [project file]

Action can be one of the following:

  • build - Compiles a project
  • bindings - Compiles the pascal bindings for Symbian OS. It supposes that the necessary files are on the location where the command is executed.
  • showpath - Shows the paths found for the Symbian SDKs and Free Pascal. Utilized to check if the tool was able to find the tools.

The project file is a .ini file with many symbian os specific informations about a project, like the UIDs

Target can be one of the following:

  • WinEmulator - Builds for the x86 emulator
  • ArmDevice - Builds a binary for use on PDAs and Smartphones

Note: The tool parameters are not case-sensitive

Screenshots

First pascal symbian os UIQ 3 application:

First pascal symbian app.PNG

See Also

External Links

  • http://developer.uiq.com/ - UIQ version 3 and superior developer community, with SDK download, Forum, Documentation and News.
  • [1] docs for the POSIX layer
  • [2] a bit of description for the POSIX layer
  • [3] - Compiling perl for symbian. They mainly use the POSIX libraries...
  • [4] - List of the UIQ Phones and the UIQ SDK version to use.
  • [5] - APIs changed from UIQ 2.1 to UIQ 3
  • [6] - How to port my application from UIQ 2.x to UIQ 3