Join Now

Random thoughts about mobile (enterprise) application development.

An Open C test drive

widianuser | 20 August, 2007 22:38

Some time ago I decided to test drive Open C to see how the first release performs. Instead of writing my own code from scratch, I took an existing open source project and tried to port that to Symbian. Because once upon a time I considered writing my own XMPP Symbian implementation, I downloaded sources for Loudmouth, an open source XMPP implementation. Without previous knowledge about Open C or Loudmouth I took the challenge. Below are some notes about my Open C tests. List is not very "scientific" and all comments are more than welcome!

Starting the work was simple: I created a new DLL-type project using Carbide and imported Loudmouth source and header files to correct directories. I was happy to see that MMP-file was updated automatically! After done that, Carbide tried to compile the project and produced a respectable amount of errors and warnings. The reason is that when compiling Loudmouth (or any other source package) to other platforms you'd use provided configuration scripts to create makefiles. For Open C that didn't work and configuration must be done manually. Basically there are two issues to solve:
  • which macros to define for compilation?
  • which libraries are required for linking?

Writing configuration manually is not as bad as it sounds: I created new header file named "configure.h" and copied the initial contents from skeleton file configuration.h.in. Luckily enough, the skeleton file was well commented and after a couple of trials and errors I got a working configuration file.

Because I was compiling a shared library, I had to add EXPORT_C and IMPORT_C directives by hand.

There is a nice set of string conversion utilities in directory s60opencexOpenCStringUtilitiesExLibrary. I didn't find any references to those from documentation.

When compiling the sources I had to make a couple of changes to support Symbian. There were only few places that needed fixing and/or "#ifdeffing" with __SYMBIAN32__ macro:
  • glib/gi18n.h includes libintl.h that wasn't included in Open C package (bug?). I simply commented that line out.
  • For target build there was error "stdapis/machine/endian.h error: impossible constraint in `asm'".  I added new preprocessor directive #ifdef __SYMBIAN32__ #define    _BYTEORDER_FUNC_DEFINED #endif to solve that

For IP-address resolving I found a strange issue: I wasn't able to get getaddrinfo() to work, but gethostbyname() seems to be OK. Can anyone else confirm this?

To run the application in target device, it is a must to install also the Open C runtime libraries, probably the best way to do this is to embed the required SIS files to one big installation file. Open C documentation seems to lack the list of required runtime libraries, but the information can be found from readme-file.

Readme file contains an error: UID for openc_ssl.sis is wrong in readme-file, correct uid is 0x10281F34.

After these steps I was able to run a small test application that linked with Loudmouth XMPP library and sent some XMPP messages to test server. I'm sure there are lots of things to polish if I continue work with this project, after all I haven't really tested the results of my small project. But anyway: getting an XMPP library compiled for Symbian takes much less time than reading and understanding the actual protocol specifiction.

Comments

Re: An Open C test drive

JEZEQUEL Romain | 27/11/2007, 17:36

I also face a problem with getaddrinfo()... Does not seems to work....

no problem with gethostbyname!

Re: An Open C test drive

mgroeber9110 | 21/08/2007, 12:29

One note on the suggestion to embed the Open C runtime libraries - there is actually a bug in the Symbian installer at the moment (on all 3rd Edition phones, I believe) that means that this will always remove the Open C libraries once you uninstall your package, even if there are other packages still depending on it.

Re: An Open C test drive

widianuser | 22/08/2007, 16:26

You can also add Open C libraries as a requirement to your pkg file (Forum Nokia Wiki or S60 SDK documentation have good examples on this). Either way you do it, the simple idea is to ensure that you don't waste time on debugging why the application doesn't start at all (I did that on one device just to realize that Open C packages were not installed)
You must login to post comments. Login
 
 
Powered by LifeType
     
     RDF Facets:
     
     
     qfnZtopicQUqfnTopicZopenE5fcQ
     qfnZtypeQUqfnTypeZBlogContentQ
     qfnZtypeQUqfnTypeZBlogE45ntryQ
     qfnZtypeQUqfnTypeZCommunityContentQ
     qfnZtypeQUqfnTypeZWebpageQ
     qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX