Incorporating C Codes into Symbian Projects

Symbian developers are not too many to find, especially in Indonesia. The community is perhaps bigger at some other countries, but it is still so little compared to desktop-based programming communities. We can view the desktop-based programming communities as the mainstream communities, which are way more mature than the Symbian programming community.

If you are a professional Symbian mobile application developer, there may come occasions when you got to integrate some C-based source codes into your application. Chances are when your supervisor ask you to handle features that Symbian OS currently not support. You and your team may need a considerable amount of time to implement these features on your own : researching, developing, testing, debugging, etc, while your boss wants you to finish the job A.S.A.P. Now, take a broader view, consider that those features are not exactly brand new, as other programmers have already developed them on some open-source platforms. So, perhaps the wisest choice would be to integrate these open-source codes with your Symbian application.

It would be no surprise if you find these source codes are written in C. On lower-level programming where efficiency and being compact are key factors, you can always consider writing in C as a good choice. There are no guarantee that you can run these C codes in your Symbian-based handphone anyway, but I’m sure that most of them will fit your need.

Now, let’s speak about the technical part. I would recommend to place the C source and header files in different directory than the rest of your application files. Perhaps you can write a new directory at your application’s src directory to place your source files and another new directory  at your application’s inc directory for the corresponding header files.

Symbian supports library of C functions that may be used. However you’ve got to realize that the headers for these libraries are not placed the default system include directory i.e \epoc32\include, as they are placed at \epoc32\include\libc.

To call the C-code functions you have to inform the compiler that you’re invoking C codes. As a result, you will have to include the C header files a little bit differently,
something like this:

extern "C" {
#include "basic.h"
#include "encrypt.h"
#include "decrypt.h"
}

The last but not the least, You may need to link against estlib.lib, the Symbian C standard library. Otherwise, you will find error messages such as undefined reference to `malloc’ or undefined reference to `free’.

Leave a Reply