Symbian
Symbian OS Library

FAQ-0901 How do I use a static library as part of a kernel-side DLL?

[Index][spacer] [Previous] [Next]



 

Classification: C++ Category: Base
Created: 07/17/2003 Modified: 07/17/2003
Number: FAQ-0901
Platform: Symbian OS v6.1, Symbian OS v7.0, Symbian OS v7.0s

Question:
I have a library of code that is built as a ".lib", that I want to link into a kernel-side DLL such as a device driver or kernel extension. The DLL is built with one of the Mxxxx target types, how do I build my library to link with it?

Answer:
Code running on a Symbian OS phone conforms to a particular Application Binary Interface (ABI). In a typical phone this ABI is different for user-side code (eg regular applications) and kernel side code (eg device drivers). User side code can use the ARMI, ARM4 or THUMB ABIs (ARMI works on all phones). All Symbian OS phones currently use ARM4 as the ABI for kernel side code. The Kernel-side ABI is defined as part of the ASSP build target (Mxxxx) for the phone.

    In order to use a static library with kernel side code, you must add the keyword 'asspapi' to the mmp file that builds it. This provides the hint to the toolchain that your library should be built and stored in the ABI directory for kernel code (i.e. ARM4). Here is a simple mmp file that demonstrates this:
      // lib.mmp
      //
      // Copyright (c) 2003 Symbian Ltd.  All rights reserved.
      //
      // The mmp file for a library of code to use kernel-side

      target mylib.lib
      targettype lib

      // mark this library for use kernel-side
      asspabi

      source lib.c
      As is often the case, this library contains C code that will be called by the C++ Symbian OS DLL. A sample project is attached, that includes a '.lib' file, and an LDD (Logical Device Driver) DLL which calls it. Note that the code doesn't actually do much, and is intended to demonstrate the appropriate usage of mmp files to use static libraries kernel side.