99300-AndroidPlatformNotes.page 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. POCO C++ Libraries Android Platform Notes
  2. AAAIntroduction
  3. !!!Introduction
  4. Starting with release 1.4.2 the POCO C++ Libraries can be used on
  5. Android, using the NDK r6. The gmake-based build system (also used
  6. for Mac OS X, Linux, etc.) is used to build the libraries.
  7. A standalone "customized" toolchain for Android (see below) is required.
  8. !!!Requirements
  9. !!Standalone Toolchain
  10. Please refer to the Android NDK Dev Guide document "Standalone Toolchain", section 3,
  11. (<*docs/STANDALONE-TOOLCHAIN.html*>) for instructions how to create a customized toolchain.
  12. Typically, you'll run a command like:
  13. $NDK/build/tools/make-standalone-toolchain.sh --platform=android-8 --install-dir=$HOME/my-android-toolchain
  14. ----
  15. Then, add the directory containing the toolchain executables to your <[$PATH]>:
  16. export PATH=$PATH:$HOME/my-android-toolchain/bin
  17. ----
  18. !!Compiling the POCO C++ Libraries
  19. When compiling the POCO C++ Libraries for a Android target, as well as
  20. when including POCO C++ Libraries headers in a project for a Android
  21. target, the preprocessor macro <[POCO_ANDROID]> must be defined. This is
  22. because the Android NDK GCC compiler does not provide a predefined macro that
  23. allows for reliable detection of an Android target.
  24. !!!Restrictions
  25. For the most part, the Linux and Android ports of the POCO C++ Libraries are very similar.
  26. However, there are a few restrictions due to the Binoic C library used by Android.
  27. !!Poco::NamedEvent and Poco::NamedMutex
  28. These classes are not supported on Android. While Poco::NamedEvent and
  29. Poco::NamedMutex objects can be created, any attempt to call a method
  30. of these classes will result in a Poco::NotImplementedException being thrown.
  31. !!Poco::SharedMemory
  32. Shared memory is not supported on Android.
  33. !!Poco::FPEnvironment
  34. The Poco::FPEnvironment class is not available on Android and
  35. cannot be used.
  36. !!Poco::RWLock
  37. On Android, Poco::RWLock is an ordinary mutex.
  38. !!!Build Notes
  39. !!Using POCO's GNU Make-based Build System
  40. The <*Android*> build configuration (located in <*$POCO_BASE/build/config/Android*>)
  41. is used to cross-build for Android from a Linux or Mac OS X host.
  42. To build the POCO C++ Libraries (static) on a Linux or Mac OS X host:
  43. ./configure --config=Android --no-samples --no-tests
  44. ./make -s -j4
  45. ----
  46. The default configuration builds for the <*armeabi*> platform ABI. To build for
  47. <*armeabi-v7a*>, set the <[ANDROID_ABI]> make variable to <[armeabi-v7a]>:
  48. ./make -s -j4 ANDROID_ABI=armeabi-v7a
  49. ----
  50. The build configuration also supports setting the <[ANDROID_ABI]> to <[x86]>,
  51. but the NDK r6 standalone toolchain for x86 generated by <*make-standalone-toolchain.sh*>
  52. lacks the C++ STL headers, so this does not work.
  53. Depending on your specific requirements (e.g., no ARM architecture, etc.), it may be necessary
  54. to modify the Android build configuration, or create a new one based on it.
  55. See the [[99150-GMakeBuildNotes.html GNU Make Build System]] document for more information.
  56. !!Using Android's Build System
  57. Alternatively to POCO's build system, Android's build system can be used to build the
  58. POCO C++ Libraries. A sample makefile for the Foundation library is shown below.
  59. #
  60. # Android.mk
  61. #
  62. # POCO Foundation
  63. #
  64. include $(CLEAR_VARS)
  65. LOCAL_MODULE := PocoFoundation
  66. LOCAL_PATH := $(call my-dir)/src
  67. LOCAL_CFLAGS := -DPOCO_ANDROID -DPOCO_NO_FPENVIRONMENT -DPOCO_NO_WSTRING -DPOCO_NO_SHAREDMEMORY
  68. LOCAL_CPPFLAGS := -frtti -fexceptions
  69. LOCAL_C_INCLUDES := $(call my-dir)/include
  70. LOCAL_SRC_FILES := \
  71. AbstractObserver.cpp \
  72. ActiveDispatcher.cpp \
  73. adler32.c \
  74. ArchiveStrategy.cpp \
  75. Ascii.cpp \
  76. ASCIIEncoding.cpp \
  77. AsyncChannel.cpp \
  78. AtomicCounter.cpp \
  79. Base64Decoder.cpp \
  80. Base64Encoder.cpp \
  81. BinaryReader.cpp \
  82. BinaryWriter.cpp \
  83. Bugcheck.cpp \
  84. ByteOrder.cpp \
  85. Channel.cpp \
  86. Checksum.cpp \
  87. compress.c \
  88. Condition.cpp \
  89. Configurable.cpp \
  90. ConsoleChannel.cpp \
  91. CountingStream.cpp \
  92. crc32.c \
  93. DateTime.cpp \
  94. DateTimeFormat.cpp \
  95. DateTimeFormatter.cpp \
  96. DateTimeParser.cpp \
  97. Debugger.cpp \
  98. deflate.c \
  99. DeflatingStream.cpp \
  100. DigestEngine.cpp \
  101. DigestStream.cpp \
  102. DirectoryIterator.cpp \
  103. DynamicAny.cpp \
  104. DynamicAnyHolder.cpp \
  105. Environment.cpp \
  106. ErrorHandler.cpp \
  107. Event.cpp \
  108. EventArgs.cpp \
  109. Exception.cpp \
  110. File.cpp \
  111. FileChannel.cpp \
  112. FileStream.cpp \
  113. FileStreamFactory.cpp \
  114. Format.cpp \
  115. Formatter.cpp \
  116. FormattingChannel.cpp \
  117. FPEnvironment.cpp \
  118. Glob.cpp \
  119. gzio.c \
  120. Hash.cpp \
  121. HashStatistic.cpp \
  122. HexBinaryDecoder.cpp \
  123. HexBinaryEncoder.cpp \
  124. infback.c \
  125. inffast.c \
  126. inflate.c \
  127. InflatingStream.cpp \
  128. inftrees.c \
  129. Latin1Encoding.cpp \
  130. Latin9Encoding.cpp \
  131. LineEndingConverter.cpp \
  132. LocalDateTime.cpp \
  133. LogFile.cpp \
  134. Logger.cpp \
  135. LoggingFactory.cpp \
  136. LoggingRegistry.cpp \
  137. LogStream.cpp \
  138. Manifest.cpp \
  139. MD2Engine.cpp \
  140. MD4Engine.cpp \
  141. MD5Engine.cpp \
  142. MemoryPool.cpp \
  143. MemoryStream.cpp \
  144. Message.cpp \
  145. Mutex.cpp \
  146. NestedDiagnosticContext.cpp \
  147. Notification.cpp \
  148. NotificationCenter.cpp \
  149. NotificationQueue.cpp \
  150. NullChannel.cpp \
  151. NullStream.cpp \
  152. NumberFormatter.cpp \
  153. NumberParser.cpp \
  154. Path.cpp \
  155. PatternFormatter.cpp \
  156. pcre_chartables.c \
  157. pcre_compile.c \
  158. pcre_exec.c \
  159. pcre_fullinfo.c \
  160. pcre_globals.c \
  161. pcre_maketables.c \
  162. pcre_newline.c \
  163. pcre_ord2utf8.c \
  164. pcre_study.c \
  165. pcre_tables.c \
  166. pcre_try_flipped.c \
  167. pcre_ucd.c \
  168. pcre_valid_utf8.c \
  169. pcre_xclass.c \
  170. Pipe.cpp \
  171. PipeImpl.cpp \
  172. PipeStream.cpp \
  173. PriorityNotificationQueue.cpp \
  174. Process.cpp \
  175. PurgeStrategy.cpp \
  176. Random.cpp \
  177. RandomStream.cpp \
  178. RefCountedObject.cpp \
  179. RegularExpression.cpp \
  180. RotateStrategy.cpp \
  181. Runnable.cpp \
  182. RWLock.cpp \
  183. Semaphore.cpp \
  184. SHA1Engine.cpp \
  185. SharedLibrary.cpp \
  186. SharedMemory.cpp \
  187. SignalHandler.cpp \
  188. SimpleFileChannel.cpp \
  189. SplitterChannel.cpp \
  190. Stopwatch.cpp \
  191. StreamChannel.cpp \
  192. StreamConverter.cpp \
  193. StreamCopier.cpp \
  194. StreamTokenizer.cpp \
  195. String.cpp \
  196. StringTokenizer.cpp \
  197. SynchronizedObject.cpp \
  198. SyslogChannel.cpp \
  199. Task.cpp \
  200. TaskManager.cpp \
  201. TaskNotification.cpp \
  202. TeeStream.cpp \
  203. TemporaryFile.cpp \
  204. TextBufferIterator.cpp \
  205. TextConverter.cpp \
  206. TextEncoding.cpp \
  207. TextIterator.cpp \
  208. Thread.cpp \
  209. ThreadLocal.cpp \
  210. ThreadPool.cpp \
  211. ThreadTarget.cpp \
  212. TimedNotificationQueue.cpp \
  213. Timer.cpp \
  214. Timespan.cpp \
  215. Timestamp.cpp \
  216. Timezone.cpp \
  217. Token.cpp \
  218. trees.c \
  219. UnicodeConverter.cpp \
  220. Unicode.cpp \
  221. URI.cpp \
  222. URIStreamFactory.cpp \
  223. URIStreamOpener.cpp \
  224. UTF8Encoding.cpp \
  225. UTF8String.cpp \
  226. UTF16Encoding.cpp \
  227. UUID.cpp \
  228. UUIDGenerator.cpp \
  229. Void.cpp \
  230. Windows1252Encoding.cpp \
  231. zutil.c
  232. include $(BUILD_STATIC_LIBRARY)
  233. ----