Project

General

Profile

Installing Wt on Android » History » Version 1

Wim Dumon, 09/07/2010 03:34 PM

1 1 Wim Dumon
h1. Installing Wt on Android
2
3
Warning: Installation of Wt on Android is a bit more complex than it should be. The dependencies (NDK, boost) don't support this platform perfectly, and thus you must be prepared to patch these if you encounter problems. This page describes how I made my first Wt on Android build.
4
5
h2. Installing the cross tools
6
7
At the time of writing, Google's NDK C++ support is insufficient to compile boost or Wt. Use the crystax NDK, a fork of the official Google NDK, instead. Download the prebuilt tools for your platform and install them somewhere.
8
9
h2. Compiling boost
10
11
I used boost 1.44.0. Download and unpack it somewhere.
12
13
Run the bootstrap script to compile bjam.
14
15
Edit the boost_1_44_0/project-config.jam file to add some defaults. I made the following changes:
16
<pre>
17
# Python configuration
18
#using python : 2.6 : /usr ;
19
20
libraries = --with-date_time --with-filesystem --with-program_options --with-regex --with-signals --with-system --with-thread ; 
21
22
# These settings are equivivalent to corresponding command-line
23
# options.
24
option.set prefix : /home/wim/project/android/boost ;
25
option.set exec-prefix : /home/wim/project/android/boost ;
26
option.set libdir : /home/wim/project/android/boost/lib ;
27
option.set includedir : /home/wim/project/android/boost/include ;
28
</pre>
29
30
In boost_1_44_0/tools/build/v2/user-config.jam, add the following lines (modify paths to your NDK installation directory as needed):
31
<pre>
32
using gcc : arm : /home/wim/project/android/android-ndk-r4-crystax/build/prebuilt/linux-x86/arm-eabi-4.4.0/bin/arm-eabi-c++ :
33
<compileflags>-I/home/wim/project/android/android-ndk-r4-crystax/build/platforms/android-8/arch-arm/usr/include/
34
<compileflags>-fpic
35
<compileflags>-mthumb-interwork
36
<compileflags>-ffunction-sections
37
<compileflags>-funwind-tables
38
<compileflags>-fstack-protector
39
<compileflags>-fno-short-enums
40
<compileflags>-D__ARM_ARCH_5__
41
<compileflags>-D__ARM_ARCH_5T__
42
<compileflags>-D__ARM_ARCH_5E__
43
<compileflags>-D__ARM_ARCH_5TE__
44
<compileflags>-Wno-psabi
45
<compileflags>-march=armv5te
46
<compileflags>-mtune=xscale
47
<compileflags>-msoft-float
48
<compileflags>-mthumb
49
<compileflags>-Os
50
<compileflags>-fomit-frame-pointer
51
<compileflags>-fno-strict-aliasing
52
<compileflags>-finline-limit=64
53
<compileflags>-DANDROID
54
<compileflags>-D__ANDROID__
55
<compileflags>-Wa,--noexecstack
56
# 'official' android flags stop here
57
<architecture>arm
58
<compileflags>-fvisibility=hidden
59
<compileflags>-fvisibility-inlines-hidden
60
<compileflags>-fdata-sections
61
<cxxflags>-DBOOST_THREAD_LINUX
62
<cxxflags>-DBOOST_HAS_PTHREADS
63
<cxxflags>-D__arm__
64
<cxxflags>-D_REENTRANT
65
<cxxflags>-D_GLIBCXX__PTHREADS
66
<cxxflags>-DBOOST_HAS_GETTIMEOFDAY
67
;
68
69
</pre>
70
71
You'll need to patch boost. This is a diff of my patched boost against an original one:
72
<pre>
73
diff -ru orig/boost_1_44_0/boost/asio/detail/fenced_block.hpp boost_1_44_0/boost/asio/detail/fenced_block.hpp
74
--- orig/boost_1_44_0/boost/asio/detail/fenced_block.hpp	2010-07-12 01:42:34.000000000 +0200
75
+++ boost_1_44_0/boost/asio/detail/fenced_block.hpp	2010-09-02 10:43:21.000000000 +0200
76
@@ -25,14 +25,14 @@
77
 # include <boost/asio/detail/macos_fenced_block.hpp>
78
 #elif defined(__sun)
79
 # include <boost/asio/detail/solaris_fenced_block.hpp>
80
-#elif defined(__GNUC__) && defined(__arm__)
81
+#elif defined(__GNUC__) && defined(__arm__) && !defined(__thumb__)
82
 # include <boost/asio/detail/gcc_arm_fenced_block.hpp>
83
 #elif defined(__GNUC__) && (defined(__hppa) || defined(__hppa__))
84
 # include <boost/asio/detail/gcc_hppa_fenced_block.hpp>
85
 #elif defined(__GNUC__) \
86
   && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4)) \
87
   && !defined(__INTEL_COMPILER) && !defined(__ICL) \
88
-  && !defined(__ICC) && !defined(__ECC) && !defined(__PATHSCALE__)
89
+  && !defined(__ICC) && !defined(__ECC) && !defined(__PATHSCALE__) && !defined(ANDROID)
90
 # include <boost/asio/detail/gcc_sync_fenced_block.hpp>
91
 #elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
92
 # include <boost/asio/detail/gcc_x86_fenced_block.hpp>
93
@@ -54,14 +54,14 @@
94
 typedef macos_fenced_block fenced_block;
95
 #elif defined(__sun)
96
 typedef solaris_fenced_block fenced_block;
97
-#elif defined(__GNUC__) && defined(__arm__)
98
+#elif defined(__GNUC__) && defined(__arm__) && !defined(__thumb__)
99
 typedef gcc_arm_fenced_block fenced_block;
100
 #elif defined(__GNUC__) && (defined(__hppa) || defined(__hppa__))
101
 typedef gcc_hppa_fenced_block fenced_block;
102
 #elif defined(__GNUC__) \
103
   && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4)) \
104
   && !defined(__INTEL_COMPILER) && !defined(__ICL) \
105
-  && !defined(__ICC) && !defined(__ECC) && !defined(__PATHSCALE__)
106
+  && !defined(__ICC) && !defined(__ECC) && !defined(__PATHSCALE__) && !defined(ANDROID)
107
 typedef gcc_sync_fenced_block fenced_block;
108
 #elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
109
 typedef gcc_x86_fenced_block fenced_block;
110
diff -ru orig/boost_1_44_0/boost/asio/detail/socket_types.hpp boost_1_44_0/boost/asio/detail/socket_types.hpp
111
--- orig/boost_1_44_0/boost/asio/detail/socket_types.hpp	2010-06-09 11:40:46.000000000 +0200
112
+++ boost_1_44_0/boost/asio/detail/socket_types.hpp	2010-09-01 19:10:27.000000000 +0200
113
@@ -121,7 +121,11 @@
114
 typedef int socket_type;
115
 const int invalid_socket = -1;
116
 const int socket_error_retval = -1;
117
+#ifdef INET_ADDRSTRLEN
118
 const int max_addr_v4_str_len = INET_ADDRSTRLEN;
119
+#else
120
+const int max_addr_v4_str_len = 16;
121
+#endif
122
 #if defined(INET6_ADDRSTRLEN)
123
 const int max_addr_v6_str_len = INET6_ADDRSTRLEN + 1 + IF_NAMESIZE;
124
 #else // defined(INET6_ADDRSTRLEN)
125
diff -ru orig/boost_1_44_0/boost/asio/ip/impl/address_v6.ipp boost_1_44_0/boost/asio/ip/impl/address_v6.ipp
126
--- orig/boost_1_44_0/boost/asio/ip/impl/address_v6.ipp	2010-06-09 11:40:46.000000000 +0200
127
+++ boost_1_44_0/boost/asio/ip/impl/address_v6.ipp	2010-09-01 19:10:27.000000000 +0200
128
@@ -11,6 +11,23 @@
129
 #ifndef BOOST_ASIO_IP_IMPL_ADDRESS_V6_IPP
130
 #define BOOST_ASIO_IP_IMPL_ADDRESS_V6_IPP
131
 
132
+#ifndef IN6_IS_ADDR_MULTICAST 
133
+#define IN6_IS_ADDR_MULTICAST(a) (((__const uint8_t *) (a))[0] == 0xff)
134
+#endif
135
+
136
+#ifndef IN6_IS_ADDR_MC_NODELOCAL
137
+#define IN6_IS_ADDR_MC_NODELOCAL(a) \
138
+        (IN6_IS_ADDR_MULTICAST(a)                                             \
139
+         && ((((__const uint8_t *) (a))[1] & 0xf) == 0x1))
140
+#endif
141
+
142
+#ifndef IN6_IS_ADDR_MC_GLOBAL
143
+#define IN6_IS_ADDR_MC_GLOBAL(a) \
144
+        (IN6_IS_ADDR_MULTICAST(a)                                             \
145
+         && ((((__const uint8_t *) (a))[1] & 0xf) == 0xe))
146
+#endif
147
+
148
+
149
 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
150
 # pragma once
151
 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
152
Only in boost_1_44_0/: bootstrap.log
153
diff -ru orig/boost_1_44_0/libs/filesystem/v2/src/v2_operations.cpp boost_1_44_0/libs/filesystem/v2/src/v2_operations.cpp
154
--- orig/boost_1_44_0/libs/filesystem/v2/src/v2_operations.cpp	2010-08-10 22:00:09.000000000 +0200
155
+++ boost_1_44_0/libs/filesystem/v2/src/v2_operations.cpp	2010-09-02 17:38:22.000000000 +0200
156
@@ -58,14 +58,16 @@
157
 
158
 # else // BOOST_POSIX_API
159
 #   include <sys/types.h>
160
-#   if !defined(__APPLE__) && !defined(__OpenBSD__)
161
+#   if !defined(__APPLE__) && !defined(__OpenBSD__) && !defined(ANDROID)
162
 #     include <sys/statvfs.h>
163
 #     define BOOST_STATVFS statvfs
164
 #     define BOOST_STATVFS_F_FRSIZE vfs.f_frsize
165
 #   else
166
-#ifdef __OpenBSD__
167
-#     include <sys/param.h>
168
-#endif
169
+#     ifdef __OpenBSD__
170
+#       include <sys/param.h>
171
+#     elif defined(ANDROID)
172
+#       include <sys/vfs.h>
173
+#     endif
174
 #     include <sys/mount.h>
175
 #     define BOOST_STATVFS statfs
176
 #     define BOOST_STATVFS_F_FRSIZE static_cast<boost::uintmax_t>( vfs.f_bsize )
177
@@ -1262,7 +1264,20 @@
178
         if ( max == 0 )
179
         {
180
           errno = 0;
181
+#ifdef ANDROID
182
+          long tmp = 4096; // is it?
183
+#if 0
184
+          {
185
+            int fd = open( "/", O_RDONLY );
186
+            if (fd >= 0) {
187
+              tmp = ::fpathconf( fd, _PC_NAME_MAX );
188
+              close(fd);
189
+            }
190
+          }
191
+#endif
192
+#else
193
           long tmp = ::pathconf( "/", _PC_NAME_MAX );
194
+#endif
195
           if ( tmp < 0 )
196
           {
197
             if ( errno == 0 ) // indeterminate
198
Only in boost_1_44_0/libs/filesystem/v2/src: v2_operations.cpp~
199
diff -ru orig/boost_1_44_0/libs/filesystem/v3/src/operations.cpp boost_1_44_0/libs/filesystem/v3/src/operations.cpp
200
--- orig/boost_1_44_0/libs/filesystem/v3/src/operations.cpp	2010-08-10 22:00:09.000000000 +0200
201
+++ boost_1_44_0/libs/filesystem/v3/src/operations.cpp	2010-09-01 19:10:27.000000000 +0200
202
@@ -66,13 +66,15 @@
203
 # ifdef BOOST_POSIX_API
204
 
205
 #   include <sys/types.h>
206
-#   if !defined(__APPLE__) && !defined(__OpenBSD__)
207
+#   if !defined(__APPLE__) && !defined(__OpenBSD__) && !defined(ANDROID)
208
 #     include <sys/statvfs.h>
209
 #     define BOOST_STATVFS statvfs
210
 #     define BOOST_STATVFS_F_FRSIZE vfs.f_frsize
211
 #   else
212
 #     ifdef __OpenBSD__
213
 #     include <sys/param.h>
214
+#     elif defined(ANDROID)
215
+#       include <sys/vfs.h>
216
 #     endif
217
 #     include <sys/mount.h>
218
 #     define BOOST_STATVFS statfs
219
@@ -193,7 +195,19 @@
220
          || ::mkdir(to.c_str(),from_stat.st_mode)!= 0))
221
 #   define BOOST_COPY_FILE(F,T,FailIfExistsBool)copy_file_api(F, T, FailIfExistsBool)
222
 #   define BOOST_MOVE_FILE(OLD,NEW)(::rename(OLD, NEW)== 0)
223
+#ifndef ANDROID
224
 #   define BOOST_RESIZE_FILE(P,SZ)(::truncate(P, SZ)== 0)
225
+#else
226
+int BOOST_RESIZE_FILE(const char *path, off_t size)
227
+{
228
+  int retval = -1;
229
+  int fd = open(path, O_WRONLY);
230
+  if (fd != -1)
231
+    retval = ftruncate(fd, size);
232
+  close(fd);
233
+  return retval;
234
+}
235
+#endif
236
 
237
 #   define BOOST_ERROR_NOT_SUPPORTED ENOSYS
238
 #   define BOOST_ERROR_ALREADY_EXISTS EEXIST
239
diff -ru orig/boost_1_44_0/tools/build/v2/tools/gcc.jam boost_1_44_0/tools/build/v2/tools/gcc.jam
240
--- orig/boost_1_44_0/tools/build/v2/tools/gcc.jam	2010-04-20 14:05:14.000000000 +0200
241
+++ boost_1_44_0/tools/build/v2/tools/gcc.jam	2010-09-01 16:37:36.000000000 +0200
242
@@ -935,8 +935,8 @@
243
             }
244
             case * :
245
             {
246
-                option = -pthread ;
247
-                libs = rt ;
248
+#                option = -pthread ;
249
+#                libs = rt ;
250
             }
251
         }
252
     
253
diff -ru orig/boost_1_44_0/tools/build/v2/tools/gcc.py boost_1_44_0/tools/build/v2/tools/gcc.py
254
--- orig/boost_1_44_0/tools/build/v2/tools/gcc.py	2009-10-28 08:47:51.000000000 +0100
255
+++ boost_1_44_0/tools/build/v2/tools/gcc.py	2010-09-01 16:36:22.000000000 +0200
256
@@ -672,12 +672,14 @@
257
         # BeOS has no threading options, don't set anything here.
258
         pass
259
     elif host_os_name.endswith('BSD'):
260
-        flags('gcc', 'OPTIONS', ['<threading>multi'], ['-pthread'])
261
+        #flags('gcc', 'OPTIONS', ['<threading>multi'], ['-pthread'])
262
         # there is no -lrt on BSD
263
+        pass
264
     elif host_os_name == 'DragonFly':
265
-        flags('gcc', 'OPTIONS', ['<threading>multi'], ['-pthread'])
266
+        #flags('gcc', 'OPTIONS', ['<threading>multi'], ['-pthread'])
267
         # there is no -lrt on BSD - DragonFly is a FreeBSD variant,
268
         # which anoyingly doesn't say it's a *BSD.
269
+        pass
270
     elif host_os_name == 'IRIX':
271
         # gcc on IRIX does not support multi-threading, don't set anything here.
272
         pass
273
@@ -685,8 +687,9 @@
274
         # Darwin has no threading options, don't set anything here.
275
         pass
276
     else:
277
-        flags('gcc', 'OPTIONS', ['<threading>multi'], ['-pthread'])
278
-        flags('gcc', 'FINDLIBS-SA', [], ['rt'])
279
+        #flags('gcc', 'OPTIONS', ['<threading>multi'], ['-pthread'])
280
+        #flags('gcc', 'FINDLIBS-SA', [], ['rt'])
281
+        pass
282
 
283
 def cpu_flags(toolset, variable, architecture, instruction_set, values, default=None):
284
     #FIXME: for some reason this fails.  Probably out of date feature code
285
286
</pre>
287
288
Now invoke bjam, and you should have a nice boost installation in the path that you specified in project-config.jam.
289
<pre>
290
./bjam link=static threading=multi --layout=versioned install
291
</pre>
292
293
h2. Preparing cmake
294
295
Create a toolchain file. Call it ~/toolchain-android.cmake
296
<pre>
297
SET(ANDROID_DIR /home/wim/project/android/)
298
SET(ANDROID_NDK_DIR ${ANDROID_DIR}/android-ndk-r4-crystax/)
299
SET(STAGING_DIR ${ANDROID_NDK_DIR}/build/prebuilt/linux-x86/arm-eabi-4.4.0/)
300
SET(TARGET_CC ${STAGING_DIR}/bin/arm-eabi-gcc)
301
SET(TARGET_CXX ${STAGING_DIR}/bin/arm-eabi-c++)
302
303
SET(CMAKE_SYSTEM_NAME Android)
304
SET(CMAKE_SYSTEM_VERSION 1)
305
306
SET(CMAKE_SYSTEM_PROCESSOR arm-elf)
307
SET(CMAKE_C_COMPILER ${TARGET_CC})
308
SET(CMAKE_CXX_COMPILER ${TARGET_CXX})
309
310
SET(CMAKE_FIND_ROOT_PATH  ${ANDROID_DIR})
311
312
# search for programs in the build host directories
313
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
314
# for libraries and headers in the target directories
315
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
316
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
317
</pre>
318
319
Create a platform file. Put it in a file called cmake/Platform/Android.cmake
320
<pre>
321
SET(ANDROID true)
322
SET(ANDROID_OPTION_LIST
323
    -I/home/wim/project/android/android-ndk-r4-crystax/build/platforms/android-8/arch-arm/usr/include
324
    -fpic
325
    -mthumb-interwork
326
    -ffunction-sections
327
    -funwind-tables
328
    -fstack-protector
329
    -fno-short-enums
330
    -D__ARM_ARCH_5__
331
    -D__ARM_ARCH_5T__
332
    -D__ARM_ARCH_5E__
333
    -D__ARM_ARCH_5TE__
334
    -Wno-psabi
335
    -march=armv5te
336
    -mtune=xscale
337
    -msoft-float
338
    -mthumb
339
    -Os
340
    -fomit-frame-pointer
341
    -fno-strict-aliasing
342
    -finline-limit=64
343
    -DANDROID
344
    -Wa,--noexecstack
345
#more options
346
    -fvisibility=hidden
347
    -fvisibility-inlines-hidden
348
    -fdata-sections
349
    -DBOOST_THREAD_LINUX
350
    -DBOOST_HAS_PTHREADS
351
    -D_REENTRANT
352
    -D_GLIBCXX__PTHREADS
353
    -DANDROID
354
    -D__ANDROID__
355
    -DBOOST_HAS_GETTIMEOFDAY
356
    -DSQLITE_OMIT_LOAD_EXTENSION
357
)
358
359
foreach(arg ${ANDROID_OPTION_LIST})
360
  set(ANDROID_COMPILE_FLAGS "${ANDROID_COMPILE_FLAGS} ${arg}")
361
endforeach(arg ${ANDROID_OPTION_LIST})
362
363
364
SET(CMAKE_CXX_COMPILE_OBJECT "<CMAKE_CXX_COMPILER>  <DEFINES> <FLAGS> ${ANDROID_COMPILE_FLAGS} -o <OBJECT> -c <SOURCE>")
365
SET(CMAKE_C_COMPILE_OBJECT "<CMAKE_C_COMPILER>  <DEFINES> <FLAGS> ${ANDROID_COMPILE_FLAGS} -o <OBJECT> -c <SOURCE>")
366
367
SET(ANDROID_NDK_PREFIX "/home/wim/project/android/android-ndk-r4-crystax/")
368
SET(ANDROID_LINK_EXE_FLAGS
369
    "-nostdlib -Bdynamic -Wl,-dynamic-linker,/system/bin/linker -Wl,--gc-sections -Wl,-z,nocopyreloc"
370
    )
371
SET(ANDROID_CRT_PRE
372
    "${ANDROID_NDK_PREFIX}/build/platforms/android-3/arch-arm/usr/lib/crtbegin_dynamic.o"
373
   )
374
SET(ANDROID_CRT_POST_LIST
375
    "${ANDROID_NDK_PREFIX}/build/platforms/android-3/arch-arm/usr/lib/libmissing.a"
376
    "${ANDROID_NDK_PREFIX}/build/prebuilt/linux-x86/arm-eabi-4.4.0/bin/../lib/gcc/arm-eabi/4.4.0/../../../../arm-eabi/lib/libstdc++.a"
377
    "${ANDROID_NDK_PREFIX}/build/prebuilt/linux-x86/arm-eabi-4.4.0/bin/../lib/gcc/arm-eabi/4.4.0/../../../../arm-eabi/lib/libsupc++.a"
378
    "${ANDROID_NDK_PREFIX}/build/prebuilt/linux-x86/arm-eabi-4.4.0/bin/../lib/gcc/arm-eabi/4.4.0/libgcc.a"
379
    "${ANDROID_NDK_PREFIX}/build/platforms/android-3/arch-arm/usr/lib/libc.so"
380
    "${ANDROID_NDK_PREFIX}/build/platforms/android-3/arch-arm/usr/lib/libm.so"
381
    "-Wl,--no-undefined"
382
    "-Wl,-z,noexecstack"
383
    "-L${ANDROID_NDK_PREFIX}/build/platforms/android-3/arch-arm/usr/lib"
384
    "-llog"
385
    "-Wl,-rpath-link=${ANDROID_NDK_PREFIX}/build/platforms/android-3/arch-arm/usr/lib"
386
    "${ANDROID_NDK_PREFIX}/build/prebuilt/linux-x86/arm-eabi-4.4.0/bin/../lib/gcc/arm-eabi/4.4.0/../../../../arm-eabi/lib/libstdc++.a"
387
    "${ANDROID_NDK_PREFIX}/build/prebuilt/linux-x86/arm-eabi-4.4.0/bin/../lib/gcc/arm-eabi/4.4.0/../../../../arm-eabi/lib/libsupc++.a"
388
    "${ANDROID_NDK_PREFIX}/build/prebuilt/linux-x86/arm-eabi-4.4.0/bin/../lib/gcc/arm-eabi/4.4.0/libgcc.a"
389
    "${ANDROID_NDK_PREFIX}/build/platforms/android-3/arch-arm/usr/lib/crtend_android.o"
390
   )
391
foreach(arg ${ANDROID_CRT_POST_LIST})
392
  set(ANDROID_CRT_POST "${ANDROID_CRT_POST} ${arg}")
393
endforeach(arg ${ANDROID_CRT_POST_LIST})
394
SET(CMAKE_CXX_LINK_EXECUTABLE "<CMAKE_C_COMPILER>  ${ANDROID_LINK_EXE_FLAGS} <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> ${ANDROID_CRT_PRE} <OBJECTS>  -o <TARGET> <LINK_LIBRARIES> ${ANDROID_CRT_POST}")
395
SET(CMAKE_C_LINK_EXECUTABLE "<CMAKE_C_COMPILER>  ${ANDROID_LINK_EXE_FLAGS} <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> ${ANDROID_CRT_PRE} <OBJECTS>  -o <TARGET> <LINK_LIBRARIES> ${ANDROID_CRT_POST}")
396
397
SET(ANDROID_LINK_SHARED_FLAGS
398
    "-nostdlib -Wl,-soname,<TARGET> -Wl,-shared,-Bsymbolic"
399
    )
400
SET(ANDROID_LINK_SHARED_LIBS_LIST
401
    "-Wl,--whole-archive"
402
    "-Wl,--no-whole-archive"
403
    "${ANDROID_NDK_PREFIX}/build/platforms/android-8/arch-arm/usr/lib/libmissing.a"
404
    "${ANDROID_NDK_PREFIX}/build/prebuilt/linux-x86/arm-eabi-4.4.0/bin/../lib/gcc/arm-eabi/4.4.0/../../../../arm-eabi/lib/libstdc++.a"
405
    "${ANDROID_NDK_PREFIX}/build/prebuilt/linux-x86/arm-eabi-4.4.0/bin/../lib/gcc/arm-eabi/4.4.0/../../../../arm-eabi/lib/libsupc++.a"
406
    "${ANDROID_NDK_PREFIX}/build/prebuilt/linux-x86/arm-eabi-4.4.0/bin/../lib/gcc/arm-eabi/4.4.0/libgcc.a"
407
    "${ANDROID_NDK_PREFIX}/build/platforms/android-8/arch-arm/usr/lib/libc.so"
408
    "${ANDROID_NDK_PREFIX}/build/platforms/android-8/arch-arm/usr/lib/libm.so"
409
    "-Wl,--no-undefined"
410
    "-Wl,-z,noexecstack"
411
    "-Wl,-rpath-link=${ANDROID_NDK_PREFIX}/build/platforms/android-8/arch-arm/usr/lib"
412
    "${ANDROID_NDK_PREFIX}/build/prebuilt/linux-x86/arm-eabi-4.4.0/bin/../lib/gcc/arm-eabi/4.4.0/../../../../arm-eabi/lib/libstdc++.a"
413
    "${ANDROID_NDK_PREFIX}/build/prebuilt/linux-x86/arm-eabi-4.4.0/bin/../lib/gcc/arm-eabi/4.4.0/../../../../arm-eabi/lib/libsupc++.a"
414
    "${ANDROID_NDK_PREFIX}/build/prebuilt/linux-x86/arm-eabi-4.4.0/bin/../lib/gcc/arm-eabi/4.4.0/libgcc.a"
415
   )
416
foreach(arg ${ANDROID_LINK_SHARED_LIBS_LIST})
417
  set(ANDROID_LINK_SHARED_LIBS "${ANDROID_LINK_SHARED_LIBS} ${arg}")
418
endforeach(arg ${ANDROID_LINK_SHARED_LIBS_LIST})
419
SET(CMAKE_CXX_CREATE_SHARED_LIBRARY
420
    "<CMAKE_C_COMPILER> ${ANDROID_LINK_SHARED_FLAGS} <CMAKE_SHARED_LIBRARY_CXX_FLAGS><LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES> ${ANDROID_LINK_SHARED_LIBS}"
421
    )
422
</pre>
423
424
Disclaimer: I'm not a specialist in writing platform files, I was looking for something that works. With this platform file, you can build both executables and shared objects (and .a files of course).
425
426
h2. Build Wt
427
428
Adjust paths as necessary. The CMAKE_MODULE_PATH is the directory where you put your Android platform file.
429
430
<pre>
431
mkdir wt-build
432
cd wt-build
433
cmake -DCMAKE_TOOLCHAIN_FILE=~/toolchain-android.cmake -DBOOST_PREFIX=~/project/android/boost/ -DBOOST_VERSION=1_44 -DBOOST_COMPILER=gcc -DCMAKE_BUILD_TYPE=Debug -DCMAKE_MODULE_PATH=/home/wim/project/android/cmake -DSHARED_LIBS=OFF ~/project/android/wt
434
</pre>
435
436
Now compile Wt:
437
<pre>
438
make -j 8
439
cd examples
440
make -j 8 -k
441
</pre>
442
443
Examples that use crypt will fail to build.
444
445
h2. Deploying and running Wt
446
447
Log in on your android device and make a temporary directory:
448
<pre>
449
$ adb shell
450
# mkdir /data/tmp
451
# cd /data/tmp
452
</pre>
453
454
Copy your executable (and all dependency files, such as the resources directory, if necessary) to the temporary directory:
455
<pre>
456
$ adb shell push hello.wt /data/tmp/hello.wt
457
</pre>
458
459
Run the executable:
460
<pre>
461
$ adb shell
462
# cd /data/tmp
463
# chmod 755 hello.wt
464
# ./hello.wt --docroot=. --http-address=0.0.0.0 --http-port=8080
465
</pre>
466
467
Set up port forwarding so that you can surf to your emulator:
468
<pre>
469
$ telnet localhost 5554
470
Android Console: type 'help' for a list of commands
471
OK
472
redir add tcp:8080:8080
473
</pre>
474
475
Point your browser to http://localhost:8080/ and enjoy your Wt application!