David 'Digit' Turner | a9e8d43 | 2009-06-01 20:38:19 +0200 | [diff] [blame^] | 1 | Android NDK Stable APIs: |
| 2 | ======================== |
| 3 | |
| 4 | This is the list of stable APIs/ABIs exposed by the Android NDK. |
| 5 | |
| 6 | I. Purpose: |
| 7 | ----------- |
| 8 | |
| 9 | Each API corresponds to a set of headers files, and a shared library file |
| 10 | that contains the corresponding implementation, and which must be linked |
| 11 | against by your native code. |
| 12 | |
| 13 | For example, to use system library "Foo", you would include a header |
| 14 | like <foo.h> in your code, then tell the build system that your native |
| 15 | module needs to link to /system/lib/libfoo.so at load-time by adding |
| 16 | the following line to your Android.mk file: |
| 17 | |
| 18 | LOCAL_LDLIBS := -lfoo |
| 19 | |
| 20 | Note that the build system automatically links the C library, the Math |
| 21 | library and the C++ support library to your native code, there is no |
| 22 | need to list them in a LOCAL_LDLIBS line. |
| 23 | |
| 24 | |
| 25 | |
| 26 | II. Android 1.5 Stable Native APIs: |
| 27 | ----------------------------------- |
| 28 | |
| 29 | All the APIs listed below are available for developing native code that |
| 30 | runs on Android 1.5 system images and above. |
| 31 | |
| 32 | The C Library: |
| 33 | -------------- |
| 34 | |
| 35 | The C library headers, as they are defined on Android 1.5 are available |
| 36 | through their standard names (<stdlib.h>, <stdio.h>, etc...). If one header |
| 37 | is not there at build time, it's because its implementation is not available |
| 38 | on a 1.5 system image. |
| 39 | |
| 40 | The build system automatically links your native modules to the C library, |
| 41 | you don't need to add it to LOCAL_LDLIBS. |
| 42 | |
| 43 | Note that the Android C library includes support for pthread (<pthread.h>), |
| 44 | so "LOCAL_LIBS := -lpthread" is not needed. The same is true for real-time |
| 45 | extensions (-lrt on typical Linux distributions). |
| 46 | |
| 47 | |
| 48 | ** VERY IMPORTANT NOTE: ****************************************************** |
| 49 | * |
| 50 | * The kernel-specific headers in <linux/...> and <asm/...> are not considered |
| 51 | * stable at this point. Avoid including them directly because some of them |
| 52 | * are likely to change in future releases of the platform. This is especially |
| 53 | * true for anything related to specific hardware definitions. |
| 54 | * |
| 55 | ****************************************************************************** |
| 56 | |
| 57 | |
| 58 | The Math Library: |
| 59 | ----------------- |
| 60 | |
| 61 | <math.h> is available, and the math library is automatically linked to your |
| 62 | native modules at build time, so there is no need to list "-lm" through |
| 63 | LOCAL_LDLIBS. |
| 64 | |
| 65 | |
| 66 | |
| 67 | C++ Library: |
| 68 | ------------ |
| 69 | |
| 70 | An *extremely* minimal C++ support API is available. For Android 1.5, this is |
| 71 | currently limited to the following headers: |
| 72 | |
| 73 | <cstddef> |
| 74 | <new> |
| 75 | <utility> |
| 76 | <stl_pair.h> |
| 77 | |
| 78 | They may not contain all definitions required by the standard. Notably, support |
| 79 | for C++ exceptions and RTTI is not available with Android 1.5 system images. |
| 80 | |
| 81 | The C++ support library (-lstdc++) is automatically linked to your native |
| 82 | modules too, so there is no need to list it through LOCAL_LDLIBS |
| 83 | |
| 84 | |
| 85 | |
| 86 | Android-specific Log Support: |
| 87 | ----------------------------- |
| 88 | |
| 89 | <android/log.h> contains various definitions that can be used to send log messages |
| 90 | to the kernel from your native code. Please have a look at its content in |
| 91 | (build/platforms/android-1.5/common/include/android/log.h), which contain many |
| 92 | informative comments on how to use it. |
| 93 | |
| 94 | You should be able to write helpful wrapper macros for your own usage to |
| 95 | access this facility. |
| 96 | |
| 97 | If you use it, your native module should link to /system/lib/liblog.so with: |
| 98 | |
| 99 | LOCAL_LDLIBS := -llog |
| 100 | |
| 101 | |
| 102 | |
| 103 | ZLib Compression Library: |
| 104 | ------------------------- |
| 105 | |
| 106 | <zlib.h> and <zconf.h> are available and can be used to use the ZLib compression |
| 107 | library available on Android 1.5 system images. Documentation for it is available |
| 108 | on the ZLib page: http://www.zlib.net/manual.html |
| 109 | |
| 110 | If you use it, your native module should link to /system/lib/libz.so with: |
| 111 | |
| 112 | LOCAL_LDLIBS := -lz |
| 113 | |