从gitlab下载源码
openconnect源码:https://gitlab/openconnect/ics-openconnect
下载后按照步骤:
git clone https://github/cernekee/ics-openconnect
cd ics-openconnect
git submodule init
git submodule update
make -C external
一般在make -C external的时候会出错
第一个错误:
执行fetch.sh脚本下载编译需要的插件的时候报错,一般是下载不过来,这时候可以手动下载也可以修改这些下载的地址
没修改前
libxml2_MIRROR_0=ftp://xmlsoft/libxml2
libxml2_MIRROR_1=http://gd.tuwien.ac.at/pub/libxml
libxml2_MIRROR_2=http://distfiles.macports/libxml2
gmp_MIRROR_0=http://ftp.gnu/gnu/gmp
gmp_MIRROR_1=https://gmplib/download/gmp
gmp_MIRROR_2=http://www.mirrorservice/sites/ftp.gnu/gnu/gmp
nettle_MIRROR_0=http://www.lysator.liu.se/~nisse/archive
nettle_MIRROR_1=http://ftp.gnu/gnu/nettle
nettle_MIRROR_2=http://gd.tuwien.ac.at/gnu/gnusrc/nettle
gnutls_MIRROR_0=https://www.gnupg/ftp/gcrypt/gnutls/v3.6
gnutls_MIRROR_1=http://ftp.heanet.ie/mirrors/ftp.gnupg/gcrypt/gnutls/v3.6
gnutls_MIRROR_2=http://gd.tuwien.ac.at/pub/gnupg/gnutls/v3.6
stoken_MIRROR_0=http://sourceforge/projects/stoken/files
stoken_SUFFIX_0=/download
oath_toolkit_MIRROR_0=http://download.savannah.gnu/releases/oath-toolkit
oath_toolkit_MIRROR_1=https://download-mirror.savannah.gnu/releases/oath-toolkit
lz4_MIRROR_0=https://github/lz4/lz4/archive
修改后的
libxml2_MIRROR_0=ftp://xmlsoft/libxml2
libxml2_MIRROR_1=http://gd.tuwien.ac.at/pub/libxml
libxml2_MIRROR_2=http://distfiles.macports/libxml2
gmp_MIRROR_0=http://ftp.gnu/gnu/gmp
gmp_MIRROR_1=https://gmplib/download/gmp
gmp_MIRROR_2=http://www.mirrorservice/sites/ftp.gnu/gnu/gmp
nettle_MIRROR_0=http://www.lysator.liu.se/~nisse/archive
nettle_MIRROR_1=http://ftp.gnu/gnu/nettle
nettle_MIRROR_2=http://gd.tuwien.ac.at/gnu/gnusrc/nettle
gnutls_MIRROR_0=https://www.gnupg/ftp/gcrypt/gnutls/v3.6
gnutls_MIRROR_1=http://ftp.heanet.ie/mirrors/ftp.gnupg/gcrypt/gnutls/v3.6
gnutls_MIRROR_2=http://gd.tuwien.ac.at/pub/gnupg/gnutls/v3.6
stoken_MIRROR_0=http://sourceforge/projects/stoken/files
stoken_SUFFIX_0=/download
oath_toolkit_MIRROR_0=http://download.savannah.gnu/releases/oath-toolkit
oath_toolkit_MIRROR_1=https://download-mirror.savannah.gnu/releases/oath-toolkit
lz4_MIRROR_0=https://github/lz4/lz4/archive
正常情况脚本可以自动下载了,如果还不行就把需要下载的直接Google搜索,单个下载吧,下载完复制到这个android的目录下就行了;
第二个错误
就是下载过来后面编译会报错
readlink: illegal option -- f
这个错误在命令行结束运行的前面十几行的样子,这个错误会导致libgmp.a编译不出来
解决这个错误的办法是:
1.安装coreutils:
brew install coreutils
2.设置环境变量,编辑~/.bash_profile,添加:
export PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH"
3.创建别名,使用greadlink替代readlink,同样是编辑~/.bash_profile,添加:
alias readlink=greadlink
然后,找到如下路径的这个脚本文件
这个脚本文件原本是用的readlink命令,这里改成greadlink就行了,别关闭这个文件,否则执行脚本的时候他自动又改回去了
到这里就不会报前面那个libgmp.a文件没编译出来的错误了
第三个错误
checking build system compiler gcc... no
checking build system compiler cc... no
checking build system compiler c89... no
checking build system compiler c99... no
configure: error: Cannot find a build system compiler
make[1]: *** [arm-linux-androideabi/nettle/Makefile] Error 1
make: *** [arm/libopenconnect.so] Error 2
ERROR: Unknown option '--system'
解决上面的错误后,会在使用nettle的时报这个错误,看config.log文件的时候,细节是这样
这是因为操作系统和编译系统不一致导致的,比如在Windows上面用Linux上的NDK编译导致这个错误,只需要对应的系统使用对应NDK即可;
第四个错误
No usable m4 in $PATH or /usr/5bin (see config.log for reasons).
由此可以看出是缺少M4文件。可以去这里下载:http://ftp.gnu/gnu/m4/,下载后解压安装
1) tar zxvf m4-1.4.1.tar.gz
2) cd m4-1.4.1
3) ./configure
4) make
5) make check(强烈建议检查,确保正确)
6) make install(需要root,建议在root中安装)
第五个错误
aclocal: 未找到命令
没找到命令就是有组件没安装,安装就行了
1. sudo apt-get install automake
2. yum -y install automake
第六个错误
./autogen.sh:行5: libtoolize: 未找到命令
又是少了组件,安装libtool即可,三者选一安装即可
- sudo apt install libtool
- wget install libtool
- yum install libtool
第七个错误
TypeError: super() takes at least 1 argument (0 given)
这是因为安装的Python版本为2.xx,而代码中的只能python3,所以安装Python3即可
第八个错误
Ubuntu Linux 解决 bash ./ 没有那个文件或目录 的方法
这是运行过程中文件丢失,查看详细日志的时候知道有cd external/stoken
我们进入这个目录的时候发现stoken下面没有任何文件,所以把原来的文件复制到这里再次执行
第九个错误
error install-sh: no input file specified
这个错误主要是external目录下的Makefile文件shell脚本有问题,是在编译stoken的动态库的时候报错,只需要把
build-stoken install-strip
改为
build-stoken install就行了
第十个错误
Android控制台输出日志
2021-08-09 19:01:09.955 9077-9077/? A/DEBUG: Abort message: 'FORTIFY: %n not allowed on Android'
2021-08-09 19:01:09.955 9077-9077/? A/DEBUG: x0 0000000000000000 x1 0000000000002370 x2 0000000000000006 x3 0000007e562f0770
2021-08-09 19:01:09.955 9077-9077/? A/DEBUG: x4 0000000000000000 x5 0000000000000000 x6 0000000000000000 x7 0000000000000018
2021-08-09 19:01:09.955 9077-9077/? A/DEBUG: x8 00000000000000f0 x9 6d40713d00c55b36 x10 0000000000000001 x11 0000000000000000
2021-08-09 19:01:09.955 9077-9077/? A/DEBUG: x12 fffffff0fffffbdf x13 0000000061110af5 x14 003291a5893c9d5c x15 00006feaeb69f34d
2021-08-09 19:01:09.955 9077-9077/? A/DEBUG: x16 0000007f49863738 x17 0000007f49841d20 x18 199999999999999a x19 00000000000022be
2021-08-09 19:01:09.955 9077-9077/? A/DEBUG: x20 0000000000002370 x21 00000000ffffffff x22 00000000ffffffff x23 0000007e562f1334
2021-08-09 19:01:09.955 9077-9077/? A/DEBUG: x24 0000007e562f0b50 x25 000000000000001d x26 000000000000006e x27 0000000000000000
2021-08-09 19:01:09.955 9077-9077/? A/DEBUG: x28 0000007e562f3008 x29 0000007e562f0810
2021-08-09 19:01:09.955 9077-9077/? A/DEBUG: sp 0000007e562f0750 lr 0000007f497f3404 pc 0000007f497f3430
2021-08-09 19:01:09.956 9077-9077/? A/DEBUG: backtrace:
2021-08-09 19:01:09.956 9077-9077/? A/DEBUG: #00 pc 0000000000073430 /apex/com.android.runtime/lib64/bionic/libc.so (abort+160) (BuildId: 084c8a81b8c78e19cd9a1ff6208e77cf)
2021-08-09 19:01:09.956 9077-9077/? A/DEBUG: #01 pc 00000000000b4c40 /apex/com.android.runtime/lib64/bionic/libc.so (__fortify_fatal(char const*, ...)+120) (BuildId: 084c8a81b8c78e19cd9a1ff6208e77cf)
2021-08-09 19:01:09.956 9077-9077/? A/DEBUG: #02 pc 00000000000b41f4 /apex/com.android.runtime/lib64/bionic/libc.so (__vfprintf+10956) (BuildId: 084c8a81b8c78e19cd9a1ff6208e77cf)
2021-08-09 19:01:09.956 9077-9077/? A/DEBUG: #03 pc 00000000000d19dc /apex/com.android.runtime/lib64/bionic/libc.so (snprintf+232) (BuildId: 084c8a81b8c78e19cd9a1ff6208e77cf)
2021-08-09 19:01:09.956 9077-9077/? A/DEBUG: #04 pc 00000000000bc6dc /data/app/app.openconnect-cjnA1m_oohwl7DizTlnmnw==/lib/arm64/libopenconnect.so (vasnprintf+2260)
经过多方查找,导致这个问题其实最根本的原因是因为Android10升级后已经明确禁用%n了,以前的版本没做明确判断,详情参考
https://android.googlesource/platform/bionic/+/master/docs/status.md
https://android.googlesource/platform/bionic/+/master/libc/stdio/vfprintf.cpp
所以基本可以判断是因为打包动态库或者jar包的时候使用的ndk或者jdk太老了所致,只需要使用最新的ndk即可
android NDK下载
jdk下载
其他错误
比如安装java的jdk,ant等,一一安装即可
linux下安装ant
linux下安装jdk
历经九九八十一难终于成功了,截图纪念一下
更多推荐
ics-openconnect编译
发布评论