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