我们公司有一个基于CSipSimple的项目,我最开始接触的时候一直没有编译成功他的so库,以前一直在忙其他的项目,所以没怎么研究。最近因为在等Android10的代码所以抽出了一点时间进行研究,并且最后成功编译出所有的so库。
环境是Ubuntu14+android-ndk-r10e-linux-x86_64
项目地址: https://code.google.com/archive/p/csipsimple/

先按照官方说明进行安装依赖库: subversion git quilt unzip wget swig2.0 python make yasm。我的make版本是3.81。

下载代码

下载以后进行解压,并且进入trunk/CSipSimple目录

查看Makefile,可以发现除了基本的so库,还可以生成其他的库

官方Wiki也有提及

直接就执行make all && make CodecPackLibs && make CodecG729 && make VideoLibs && make ScreenSharingLibs。这一步会拉去所有需要的代码,如果没有代理可能会很慢,还有一些是git协议的。为了加速,可以参考我之前的一篇文章《Git Clone使用代理》。
编译失败解决方案

修改jni/libvpx目录下的Makefile文件将38行的仓库地址改成:https://chromium.googlesource.com/webm/libvpx。继续make。


修改jni/ffmpeg/Makefile文件:将43行的仓库地址改成: https://code.videolan.org/videolan/x264.git 。继续make。


这个提示是diff patch使用失败了,但是根本原因是silk未下载下来。修改jni/silk/Makefile文件。
将第5行的地址改成:https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/bkvoice/$(silk_remote_folder).zip 。
将第18、19、20行的注释去掉。并且需要把目录下的.pc文件夹删除。


这个提示x264_bit_depth变量不存在,因为从提交记录(71ed44c7312438fac7c5c5301e45522e57127db4)就去除了这个变量。

所以我们需要将x264的仓库使用的版本改成 38a5268dbec56adea750e05c4981f3bbb176e735 。
修改jni/ffmpeg/Makefile文件,将第九行定义的版本号改成:38a5268dbec56adea750e05c4981f3bbb176e735。并且进入jni/ffmpeg/x264_src/目录,输入命令 git checkout 38a5268dbec56adea750e05c4981f3bbb176e735 ,回到CSipSimple目录。重新make。


这个问题困扰了我很久,最后发现是因为我在上一步修改x264的版本号的时候,我删除了 jni/ffmpeg/x264_src/ 目录、.pc目录、.patched_sources文件,这个时候因为补丁已经应用了,所以会出现这个失败。所以我上一步是直接进入 jni/ffmpeg/x264_src/ 目录进行git checkout操作的,没有删除了,最主要的是不能删除 .patched_sources文件 。

这个问题也困扰了我很久一直找不到解决方案,最后在找到了解决方案。修改jni/pjsip/android_toolchain/pjmedia/Video.mk文件。将59、66行的LOCAL_STATIC_LIBRARIES改成LOCAL_LDLIBS即可。


这个是没有编译成x86的so库,所以我们将文件jni/Application.mk中的第6行去除x86 mips。继续make。编译生成的so库如下。

自此所有编译完成。