Skip to content

Commit 3d9b7d6

Browse files
authored
Merge pull request #25 from dongbeiouba/android_cross
补充Android交叉编译文档
2 parents 7d8df82 + 015f8be commit 3d9b7d6

File tree

1 file changed

+32
-3
lines changed

1 file changed

+32
-3
lines changed

docs/compilation/source-compilation.md

+32-3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ sidebar_position: 2
44
# 源码编译
55

66
## 源码准备
7+
78
```bash
89
# clone master 分支代码
910
git clone https://github.com/Tongsuo-Project/Tongsuo.git
@@ -20,9 +21,11 @@ git clone https://github.com/Tongsuo-Project/Tongsuo.git
2021
- --api=x.y.z:x.y.z 为 API 版本号,是下列值之一:0.9.8, 1.0.0, 1.0.1, 1.0.2, 1.1.0, 1.1.1, 3.0,默认值:3.0,如果要编译与 openssl-1.1.1 兼容的 API,需要指定--api=1.1.1.
2122
- -Wl,-rpath,/opt/tongsuo/lib:rpath 指定编译出的 openssl 二进制程序依赖的 libcrypto.so 和 libssl.so 目录,效果与 `LD_LIBRARY_PATH``DYLD_LIBRARY_PATH`环境变量一样
2223
- --debug:如果需要 gdb 或者 lldb 调试需要加这个选项
24+
2325
## 编译安装
2426

2527
### 本地编译
28+
2629
```bash
2730
# 配置选项
2831
./config --prefix=/opt/tongsuo -Wl,-rpath,/opt/tongsuo/lib enable-ec_elgamal enable-paillier enable-ntls
@@ -36,9 +39,11 @@ make -j
3639
# 安装
3740
make install
3841
```
39-
### ios 交叉编译
42+
43+
### ios交叉编译
4044

4145
#### 编译
46+
4247
```bash
4348
# 配置环境变量
4449
export CC=clang;
@@ -57,8 +62,32 @@ perl configdata.pm --dump
5762
# 编译
5863
make -j
5964
```
60-
#### 打包
65+
66+
#### 打包
6167

6268
使用 lipo 工具打包(网上文章很多,此处略)
6369

64-
#### android 交叉编译(后续补上)
70+
### Android交叉编译
71+
72+
在macOS上编译android-arm64,步骤如下。Linux或其他操作系统仅供参考。
73+
74+
首先,安装NDK:
75+
76+
```bash
77+
# 这里以macOS为例, 下载NDK23
78+
curl -OLv https://dl.google.com/android/repository/android-ndk-r23c-darwin.zip
79+
unzip android-ndk-r23c-darwin.zip
80+
sudo cp android-ndk-r23c-darwin.zip /opt/
81+
```
82+
83+
编译Tongsuo:
84+
85+
```bash
86+
export ANDROID_NDK_ROOT=/opt/android-ndk-r23c
87+
PATH=$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/darwin-x86_64/bin:$PATH
88+
89+
# 按需配置选项
90+
./Configure android-arm64
91+
92+
make -j
93+
```

0 commit comments

Comments
 (0)