Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.

Static Library

From Wiki
Jump to: navigation, search
Article Metadata
Code ExampleArticle
Created: giri_dorna (18 May 2007)
Last edited: hamishwillee (26 Jul 2012)


Static Library Usage in Symbian OS

Symbian build tools provide the possibility to link objects into a lib file, which can be linked to other sources using the library’s headers. The use of static libraries should be seen as an option in case where no DLL is required, but modularization and low-level version control should be accomplished. As an advantage, the source files need not be given in cases where an engine is sold to developers. Also when static libraries are used from the start of a project, later it is easy to convert the application to make use of static DLL framework.

Creating a Static Library

Symbian OS has target type lib defining that the compiled object codes should be linked into a static library. As with other target types (for example, APP and DLL), this will set UID1 correctly, and no other UID definitions are needed.

Here is a sample MMP file:

// StaticLibEngExample.mmp
TARGET StaticLibEng.lib
SOURCE StaticLibEng.cpp
SYSTEMINCLUDE \epoc32\include

As a static library is just a collection of objects, it does not require to be linked against any import libraries. Hence, in the MMP file of the static library, LIBRARY and SYSTEMLIBRARY statements should not be used. Instead, the user of the static library is responsible for linking against all the required import libraries.

Using global and writable static data (WSD) in static libraries is possible but not recommended as it increases memory consumption and has limited support in the emulator. Furthermore, WSD may cause problems if the library is later converted into a static interface DLL.

Using Static Library

The user of the static library should list the static library with the statement STATICLIBRARY in its MMP file. The user of the static library must list all the dlls used by the static library in its MMP file using LIBRARY and/or SYSTEMLIBRARY statements.

Source Code

Full example: Eldtobhu(StaticLib).zip


Symbian OS: Platform-Independent Engine Development v1.0

This page was last modified on 26 July 2012, at 06:12.
41 page views in the last 30 days.