×
Namespaces

Variants
Actions
(Difference between revisions)

Quick and dirty porting of autoconf apps

From Nokia Developer Wiki
Jump to: navigation, search
Cdavies-nokia (Talk | contribs)
(New page: == Introduction == With the release of the OpenC plugin, it has become far easier to take an existing open source project to Symbian OS. Here's how to take an open source project develope...)
 
hamishwillee (Talk | contribs)
m (Hamishwillee - Bot update - Add ArticleMetaData)
 
(6 intermediate revisions by 6 users not shown)
Line 1: Line 1:
 +
{{ArticleMetaData <!-- v1.2 -->
 +
|sourcecode= <!-- Link to example source code e.g. [[Media:The Code Example ZIP.zip]] -->
 +
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
 +
|devices= <!-- Devices tested against - e.g. ''devices=Nokia 6131 NFC, Nokia C7-00'') -->
 +
|sdk= <!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Qt SDK 1.1.4]) -->
 +
|platform= <!-- Compatible platforms - e.g. Symbian^1 and later, Qt 4.6 and later -->
 +
|devicecompatability= <!-- Compatible devices e.g.: All* (must have internal GPS) -->
 +
|dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 -->
 +
|signing= <!-- Signing requirements - empty or one of: Self-Signed, DevCert, Manufacturer -->
 +
|capabilities= <!-- Capabilities required by the article/code example (e.g. Location, NetworkServices. -->
 +
|keywords= <!-- APIs, classes and methods (e.g. QSystemScreenSaver, QList, CBase -->
 +
|language= <!-- Language category code for non-English topics - e.g. Lang-Chinese -->
 +
|translated-by= <!-- [[User:XXXX]] -->
 +
|translated-from-title= <!-- Title only -->
 +
|translated-from-id= <!-- Id of translated revision -->
 +
|review-by= <!-- After re-review: [[User:username]] -->
 +
|review-timestamp= <!-- After re-review: YYYYMMDD -->
 +
|update-by= <!-- After significant update: [[User:username]]-->
 +
|update-timestamp= <!-- After significant update: YYYYMMDD -->
 +
|creationdate= 20070627
 +
|author= [[User:Cdavies-nokia]]
 +
}}
 
== Introduction ==
 
== Introduction ==
  
Line 5: Line 27:
 
I'm going to be using libxml2 [http://xmlsoft.org/] as the example project, but these steps generally work for any project.
 
I'm going to be using libxml2 [http://xmlsoft.org/] as the example project, but these steps generally work for any project.
  
== Task one: Build a bld.inf file for the project ==  
+
== Task one: Build a bld.inf file for the project ==
  
The first task when porting software to Symbian OS is to write a bld.inf file. For libraries like libxml2, this will export all the appropriate headers to the \epo32\include tree, together with a customised config.h.  
+
The first task when porting software to Symbian OS is to write a bld.inf file. For libraries like libxml2, this will export all the appropriate headers to the \epo32\include tree, together with a customised config.h.
  
 
Start by opening the appropriate Makefile.am, and locate the list of headers that are exported. In libxml2, this is:
 
Start by opening the appropriate Makefile.am, and locate the list of headers that are exported. In libxml2, this is:
  
<code>
+
<br>
xmlinc_HEADERS = \
+
<code>xmlinc_HEADERS = \
 
SAX.h \
 
SAX.h \
 
entities.h \
 
entities.h \
Line 21: Line 43:
 
</code>
 
</code>
  
Copy and paste this in to your bld.inf file, under the heading PRJ_EXPORTS. Rewrite each line to export it to an appropriate subdirectory of \epoc32\include. In this instance, we'll be exporting to \epoc32\include\libxml as shown below:
 
  
<code>
+
<br>Copy and paste this in to your bld.inf file, under the heading PRJ_EXPORTS. Rewrite each line to export it to an appropriate subdirectory of \epoc32\include. In this instance, we'll be exporting to \epoc32\include\libxml as shown below:
PRJ_EXPORTS
+
 
 +
<br>
 +
<code>PRJ_EXPORTS
 
..\include\libxml\SAX.h libxml\SAX.h
 
..\include\libxml\SAX.h libxml\SAX.h
 
..\include\libxml\entities.h libxml\entities.h
 
..\include\libxml\entities.h libxml\entities.h
Line 33: Line 56:
 
</code>
 
</code>
  
Now, create a copy of config.h.in called config.h.symbian, and add an export to your project exports to ex as so:
 
  
<code>
+
<br>Now, create a copy of config.h.in called config.h.symbian, and add an export to your project exports to ex as so:
..\config.h.symbian libxml\config.h
+
</ocde>
+
  
Now your exports are complete. From the command line, type bldmake bldfiles followed by abld export to export the headers.
+
<br>
 +
<code>..\config.h.symbian libxml\config.h
 +
</code>
 +
 
 +
 
 +
<br>Now your exports are complete. From the command line, type bldmake bldfiles followed by abld export to export the headers.
  
 
== Task two: Building an MMP file ==
 
== Task two: Building an MMP file ==
Line 45: Line 70:
 
Create an empty MMP file for your project, and add a boilerplate header to it along these lines:
 
Create an empty MMP file for your project, and add a boilerplate header to it along these lines:
  
<code>
+
<br>
TARGET         libxml2.dll
+
<code>TARGET libxml2.dll
TARGETTYPE     dll
+
TARGETTYPE dll
UID             0x1000008d 0xDEADBEEF
+
UID 0x1000008d 0xDEADBEEF
VENDORID       0   
+
VENDORID 0   
 
</code>
 
</code>
  
Where 0xDEADBEEF would be replaced by a UID you've procured from Symbian Signed.
 
  
 +
<br>Where 0xDEADBEEF would be replaced by a UID you've procured from Symbian Signed. Now, again find in Makefile.am the list of project sources, for libxml2, this is:
 +
 +
<br>
 +
<code>libxml2_la_SOURCES = SAX.c entities.c encoding.c error.c parserInternals.c  \
 +
parser.c tree.c hash.c list.c xmlIO.c xmlmemory.c uri.c  \
 +
 +
/* ... etc ... */
 +
</code>
 +
 +
 +
<br>Copy and paste this is to your MMP file, and munge each one in to a SOURCE line, as shown here:
 +
 +
<br>
 +
<code>SOURCEPATH      ..\
 +
SOURCE SAX.c
 +
SOURCE entities.c
 +
SOURCE encoding.c
 +
SOURCE error.c
 +
SOURCE parserInternals.c
 +
SOURCE parser.c
 +
SOURCE tree.c
 +
 +
/* ... etc ... */
 +
</code>
 +
 +
 +
<br>Now, add some system include paths. Minimally you'll want the stdapis directory, and the folder to which you exported all project headers. This is shown below:
 +
 +
<br>
 +
<code>SYSTEMINCLUDE  \epoc32\include
 +
SYSTEMINCLUDE  \epoc32\include\stdapis
 +
SYSTEMINCLUDE \epoc32\include\libxml
 +
</code>
 +
 +
 +
<br>Then, add a libraries line to link the project against lib.c, and assign it some capabilities and you're done.
 +
 +
For some projects it may be necessary to define the macro HAVE_CONFIG_H to include your config.h. This isn't the case with libxml, but to do that include this line in your MMP file:
 +
 +
<br>
 +
<code>MACRO HAVE_CONFIG_H
 +
</code>
 +
 +
 +
<br>
 +
 +
== Task three: Customise config.h.symbian ==
 +
 +
Now import your completed MMP file in to your favourite IDE. Next we need to customise config.h to the Symbian platform. For every entry in config.h, you need to decide if it does or does not apply to Symbian. For some entries, this is easy.
 +
 +
For example, things like:
 +
 +
<br>
 +
<code>#undef HAVE_FCNTL_H
 +
</code>
 +
 +
 +
<br>We know Symbian has this header, so change it to:
 +
 +
<br>
 +
<code>#define HAVE_FCNTL_H 1
 +
</code>
 +
 +
 +
<br>Others aren't so simple, they control the behaviour of the application. If you aren't sure what a config.h define does, just search for it in the code and read the context in which it is used, and then decide if it should be on or off.
 +
 +
Once you are finished, remember to export the headers again to update your config.h in \epoc32\include.
 +
 +
== Task four: compile and fix ==
 +
 +
Now, compile the project. If it fails to compile, then fix the compile errors. Obviously, this varies from project to project, so there can't be any specific advice for this. Libxml2 compiles flawlessly.
 +
 +
== Task five: Run and debug ==
 +
 +
Now run the application, or an application that uses the library. Again, you may encounter errors but this guide can't advise you on the specifics of fixing them.
 +
 +
== Done! ==
 +
 +
And that's that. You should now have a working Symbian executable or library. From start to finish, libxml2 took about half an hour to port.
 +
 +
Hope this helps. --[[User:Cdavies-nokia|Cdavies-nokia]] 14:35, 27 June 2007 (UTC)
  
[[Category:Symbian C++]]
+
[[Category:Open Source]] [[Category:Symbian C++]] [[Category:How To]] [[Category:Porting]] [[Category:Development Process]] [[Category:Open C/C++]][[Category:Code Snippet]]

Latest revision as of 06:39, 25 July 2012

Article Metadata
Article
Created: User:Cdavies-nokia (27 Jun 2007)
Last edited: hamishwillee (25 Jul 2012)

Contents

[edit] Introduction

With the release of the OpenC plugin, it has become far easier to take an existing open source project to Symbian OS. Here's how to take an open source project developed using autotools, and turn it in to a Symbian project fast.

I'm going to be using libxml2 [1] as the example project, but these steps generally work for any project.

[edit] Task one: Build a bld.inf file for the project

The first task when porting software to Symbian OS is to write a bld.inf file. For libraries like libxml2, this will export all the appropriate headers to the \epo32\include tree, together with a customised config.h.

Start by opening the appropriate Makefile.am, and locate the list of headers that are exported. In libxml2, this is:


xmlinc_HEADERS = \
SAX.h \
entities.h \
encoding.h \
parser.h \
 
/* ... etc ... */



Copy and paste this in to your bld.inf file, under the heading PRJ_EXPORTS. Rewrite each line to export it to an appropriate subdirectory of \epoc32\include. In this instance, we'll be exporting to \epoc32\include\libxml as shown below:


PRJ_EXPORTS
..\include\libxml\SAX.h libxml\SAX.h
..\include\libxml\entities.h libxml\entities.h
..\include\libxml\encoding.h libxml\encoding.h
..\include\libxml\parser.h libxml\parser.h
 
/* ... etc ... */



Now, create a copy of config.h.in called config.h.symbian, and add an export to your project exports to ex as so:


..\config.h.symbian libxml\config.h



Now your exports are complete. From the command line, type bldmake bldfiles followed by abld export to export the headers.

[edit] Task two: Building an MMP file

Create an empty MMP file for your project, and add a boilerplate header to it along these lines:


TARGET libxml2.dll
TARGETTYPE dll
UID 0x1000008d 0xDEADBEEF
VENDORID 0



Where 0xDEADBEEF would be replaced by a UID you've procured from Symbian Signed. Now, again find in Makefile.am the list of project sources, for libxml2, this is:


libxml2_la_SOURCES = SAX.c entities.c encoding.c error.c parserInternals.c  \
parser.c tree.c hash.c list.c xmlIO.c xmlmemory.c uri.c \
 
/* ... etc ... */



Copy and paste this is to your MMP file, and munge each one in to a SOURCE line, as shown here:


SOURCEPATH      ..\
SOURCE SAX.c
SOURCE entities.c
SOURCE encoding.c
SOURCE error.c
SOURCE parserInternals.c
SOURCE parser.c
SOURCE tree.c
 
/* ... etc ... */



Now, add some system include paths. Minimally you'll want the stdapis directory, and the folder to which you exported all project headers. This is shown below:


SYSTEMINCLUDE   \epoc32\include 
SYSTEMINCLUDE \epoc32\include\stdapis
SYSTEMINCLUDE \epoc32\include\libxml



Then, add a libraries line to link the project against lib.c, and assign it some capabilities and you're done.

For some projects it may be necessary to define the macro HAVE_CONFIG_H to include your config.h. This isn't the case with libxml, but to do that include this line in your MMP file:


MACRO HAVE_CONFIG_H



[edit] Task three: Customise config.h.symbian

Now import your completed MMP file in to your favourite IDE. Next we need to customise config.h to the Symbian platform. For every entry in config.h, you need to decide if it does or does not apply to Symbian. For some entries, this is easy.

For example, things like:


#undef HAVE_FCNTL_H



We know Symbian has this header, so change it to:


#define HAVE_FCNTL_H 1



Others aren't so simple, they control the behaviour of the application. If you aren't sure what a config.h define does, just search for it in the code and read the context in which it is used, and then decide if it should be on or off.

Once you are finished, remember to export the headers again to update your config.h in \epoc32\include.

[edit] Task four: compile and fix

Now, compile the project. If it fails to compile, then fix the compile errors. Obviously, this varies from project to project, so there can't be any specific advice for this. Libxml2 compiles flawlessly.

[edit] Task five: Run and debug

Now run the application, or an application that uses the library. Again, you may encounter errors but this guide can't advise you on the specifics of fixing them.

[edit] Done!

And that's that. You should now have a working Symbian executable or library. From start to finish, libxml2 took about half an hour to port.

Hope this helps. --Cdavies-nokia 14:35, 27 June 2007 (UTC)

This page was last modified on 25 July 2012, at 06:39.
80 page views in the last 30 days.
×