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