forked from FellowTraveler/Open-Transactions-old
-
Notifications
You must be signed in to change notification settings - Fork 0
/
INSTALL-Android.txt
318 lines (187 loc) · 9.12 KB
/
INSTALL-Android.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
OpenTransactions for ANDROID
--- Open Transactions is currently built on:
- Linux Ubuntu 2.6.32 and FreeBSD using g++.
- Mac OS X 10.6.4 (Snow Leopard) using XCode as well as gcc
- Windows 7 using MS Visual C++ 2010 Express.
- Android 8 using NDK.
--- OpenSSL version 1.0.0a (at least) is necessary, since the SAMY hash
uses WHRLPOOL. (XOR'd with SHA-512.) WHIRLPOOL is a new addition to
OpenSSL.
==> NOTE: Android still uses OpenSSL 0.9.8!! Thus, the default hash
algorithm in the Android build is SHA512, *not* SAMY! This will
be fixed as soon as the newest version of OpenSSL becomes available
for the Android platform.
--- Let me know if there are any problems, since this is new software;
this will be a living document.
NOTE: the Android build and instructions have not been updated for a while, and since then the packing libraries have been added to OT. So I'm adding the packing notes here:
---------------------------------------------------------------
INSTALL: MsgPack Library (data packing library now used by OT.)
Available here: msgpack.org
To install from command line: port install msgpack
(OR) brew install msgpack
Install instructions for all platforms:
http://wiki.msgpack.org/display/MSGPACK/QuickStart+for+C+Language
---------------------------------------------------------------
INSTALL: Google's Protocol Buffers library (another data packer.)
Available here:
http://code.google.com/p/protobuf/downloads/list
---------------------------------------------------------------
INSTALL: ZeroMQ (transport library.)
Available here:
http://www.zeromq.org/intro:get-the-software
---------------------------------------------------------------
INSTALL: Chaiscript (scripting library)
Available here:
http://www.chaiscript.com/
---------------------------------------------------------------
NOTE: OT hasn't been build on Android for a while, so it will
probably need some work to get it building again. Just let me know
if you are seriously playing with Android and I will put in the
work to to get it building again for you.
PRE-BUILD:
--- Presumably you have installed the Android SDK. I went with version 2.2
as the development platform.
--- You must install a SPECIAL version of the NDK in order to use the C++
standard libraries (which Open-Transactions does.) It's called the
CRYSTAX NDK and I found it here:
http://www.crystax.net/android/ndk-r4.php
--- I put the SDK folder, as well as the NDK folder, here:
~/Android
NOTE: YOU CAN USE ANY LOCATION YOU PREFER, BUT THIS IS WHAT I'M USING FOR THIS EXAMPLE.
So the SDK and NDK, on my system, are therefore here:
~/Android/android-sdk-mac_x86
~/Android/android-ndk-r4-crystax
(But I suppose you could install them anywhere you want, as long as you
give Eclipse the path...)
NOTE: WHENEVER YOU ARE IN AN NDK PROJECT, the Root folder is ALWAYS assumed to be the main NDK
folder, which in the above example is ~/Android/android-ndk-r4-crystax. So ALL of the other
NDK folders relevant to these instructions are found there. For example, on my computer,
the apps, external, and sources are found in these locations:
~/Android/android-ndk-r4-crystax/apps
~/Android/android-ndk-r4-crystax/external
~/Android/android-ndk-r4-crystax/sources
Make sure you CREATE ALL THREE FOLDERS ABOVE, if they do not already exist on your system
(apps, external, and sources.)
--- Your Eclipse project will be in your workspace folder. Make sure you create a link
from your project's folder to the NDK's apps folder. For example:
ln -s ~/workspace/fiatcash ~/Android/android-ndk-r4-crystax/apps/fiatcash
The above command creates a symbolic link: ~/Android/android-ndk-r4-crystax/apps/fiatcash
and points it to the folder: ~/workspace/fiatcash
This way, your code is safely in its workspace folder, but it also appears as an application
in your Android NDK's apps folder.
--- INSTALL OpenSSL and ZLIB into the external folder. You can download Android versions here:
OpenSSL:
http://android.git.kernel.org/?p=platform/external/openssl.git;a=summary
ZLIB:
http://android.git.kernel.org/?p=platform/external/zlib.git;a=summary
When you are done, they should be installed here:
~/Android/android-ndk-r4-crystax/external/openssl
~/Android/android-ndk-r4-crystax/external/zlib
NOTE: Unfortunately, that OpenSSL version will not build without a few fixes to the
Android.mk files within. If you would like to contact me, I will be happy to send you
a copy of these files. (I also built OpenSSL as a static library, so the files were adjusted
for that as well.)
FURTHER NOTE: FOR THE EXACT CHANGES YOU NEED TO MAKE, SCROLL TO THE BOTTOM OF THIS FILE.
--- Copy the entire Open-Transactions directory tree into the NDK sources folder. When done,
it will appear here:
~/Android/android-ndk-r4-crystax/sources/Open-Transactions
----------------------------------------------------------------
TO BUILD:
--- First change directory to the main NDK folder, like this:
cd ~/Android/android-ndk-r4-crystax/
--- Then to build your Android application:
make APP=fiatcash
(Assuming fiatcash is the name of your application.)
NOTE that the APP must be all-caps.
This command causes the Android build system to look for an application called fiatcash.
It will look for that application here:
~/Android/android-ndk-r4-crystax/apps/fiatcash
Inside the JNI folder of that app is your Android makefile. Here is the full path to it:
~/Android/android-ndk-r4-crystax/apps/fiatcash/jni/Android.mk
THAT makefile builds the NDK aspects of your Android application. In order for your application
to link to Open-Transactions (and OpenSSL, etc) your makefile does it like this:
--------------- BEGIN SAMPLE FIATCASH MAKEFILE (TO LINK WITH OPEN-TRANSACTIONS) ------------
#
# Fiatcash / Android
#
# See copyright notice that came with this distribution.
#
FIATCASH_PATH := $(call my-dir)
OTAPI_MAKE := sources/Open-Transactions/Android.mk
OTAPI_DIR := sources/Open-Transactions/testwallet
include $(OTAPI_MAKE)
# fiatcash...
#
include $(CLEAR_VARS)
LOCAL_PATH := $(FIATCASH_PATH)
LOCAL_MODULE := fiatcash
LOCAL_C_INCLUDES += $(LOCAL_PATH) $(OTAPI_DIR)
LOCAL_SRC_FILES := fiatcash.c
LOCAL_LDLIBS += -ldl -lz
LOCAL_SHARED_LIBRARIES := libOTAPI
include $(BUILD_SHARED_LIBRARY)
------------------ END SAMPLE MAKEFILE (DO NOT INCLUDE THIS NOTICE IN THE ACTUAL FILE) ----------
--- The above makefile will activate the Open-Transactions Android makefiles, and then
link it into your application.
--- Inside your FiatCash.java file, make sure to load the OTAPI shared library before
making any calls. Also load it before your own application. Like this:
System.LoadLibrary("OTAPI");
System.LoadLibrary("fiatcash");
--- (Test files will have to be generated separately for Android since it uses SHA512 instead of
SAMY hash.)
--- As always, the password is "test" for all the test certs that come with Open Transactions.
------------------------------------------------
--- If you don't want me to send you the OpenSSL makefiles, you can fix them yourself.
The main fix is in external/openssl/crypto/Android.mk. Near the bottom of the file, it should
look like this:
---------------- BEGIN BOTTOM OF THE FILE: external/openssl/crypto/Android.mk----------
LOCAL_CFLAGS += -DNO_WINDOWS_BRAINDEATH
include $(LOCAL_PATH)/../android-config.mk
LOCAL_C_INCLUDES += \
external/openssl \
external/openssl/include \
external/zlib
# LOCAL_SHARED_LIBRARIES += libz
# ifneq ($(TARGET_SIMULATOR),true)
# LOCAL_SHARED_LIBRARIES += libdl
# endif
LOCAL_LDLIBS += -ldl -lz
LOCAL_MODULE:= libcrypto
include $(BUILD_STATIC_LIBRARY)
-------------- END BOTTOM OF THE FILE: external/openssl/crypto/Android.mk------------
--- ALSO, near the TOP of that file, notice that I had to capitalize all the .S files:
ifeq ($(TARGET_ARCH),arm)
LOCAL_CFLAGS += -DOPENSSL_BN_ASM_MONT -DAES_ASM -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM
LOCAL_SRC_FILES:= 0.9.9-dev/bn/armv4-mont.S \
0.9.9-dev/aes/aes-armv4.S \
0.9.9-dev/sha/sha1-armv4-large.S \
0.9.9-dev/sha/sha256-armv4.S \
0.9.9-dev/sha/sha512-armv4.S
----------------------------------------------------------
--- I ALSO HAD to make some changes to external/openssl/ssl/Android.mk
Notice that both libraries are now static instead of shared...
---------- BEGIN BOTTOM OF THE FILE: external/openssl/ssl/Android.mk ------------
include $(LOCAL_PATH)/../android-config.mk
LOCAL_C_INCLUDES += $(local_c_includes)
LOCAL_STATIC_LIBRARIES += libcrypto
LOCAL_MODULE:= libssl
include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
# ssltest
LOCAL_SRC_FILES:=ssltest.c
LOCAL_C_INCLUDES += $(local_c_includes)
LOCAL_STATIC_LIBRARIES := libssl
include $(LOCAL_PATH)/../android-config.mk
LOCAL_MODULE:=ssltest
LOCAL_MODULE_TAGS := optional
include $(BUILD_EXECUTABLE)
------------------END BOTTOM OF THE FILE: external/openssl/ssl/Android.mk ------------
--- I ALSO MADE a small change to one small part of external/openssl/apps/Android.mk
Make sure it says this:
LOCAL_STATIC_LIBRARIES := \
libssl \
libcrypto
Instead of this:
LOCAL_SHARED_LIBRARIES := \
libssl \
libcrypto