pjsip使用最新源码编译 for android

最近要研究一下pjsip,所以从网上查看各种资料,下载源码,我用的ndk版本是r8d,编译步骤如下:

1.首先到官网下载源码,注意的是它有两个系列1.x和2.x,好像是2.x里面添加了视频功能,最主要的是2.1以上支持android编译,所以我选择的是2.x,下载地址:svn checkout http://svn.pjsip.org/repos/pjproject/trunk pjsip2.x

2.下载源码后,修改pjsip的编译配置pjlib\include\pj\config_site.h,写入以下内容

#define PJ_CONFIG_ANDROID 1
#include 
3.到下载的根目录pjsip2.x下面修改configure-android,在开头添加

ANDROID_NDK_ROOT=/opt/android-ndk-r8d
4.我不清楚配置错误还是源码的bug,可能在苹果上编译可以通过因为在pjmedia/src/pjmedia-audiodev下面有coreaudio_dev.m文件,没有对应的.c文件,所以make的时候,会提示

-o output/pjmedia-audiodev-arm-unknown-linux-androideabi/coreaudio_dev.o \
		../src/pjmedia-audiodev/coreaudio_dev.m 
arm-linux-androideabi-gcc: error: ../src/pjmedia-audiodev/coreaudio_dev.m: Objective-C compiler not installed on this system
make[2]: *** [output/pjmedia-audiodev-arm-unknown-linux-androideabi/coreaudio_dev.o] Error 1

所以我把pjmedia/src/pjmedia-audiodev/coreaudio_dev.m修改为pjmedia/src/pjmedia-audiodev/coreaudio_dev.c,该一下后缀就可以了

5.到下载的根目录pjsip2.x里面,运行./configure-android

最后会出现

Configurations for current target have been written to 'build.mak', and 'os-auto.mak' in various build directories, and pjlib/include/pj/compat/os_auto.h.

Further customizations can be put in:
  - 'user.mak'
  - 'pjlib/include/pj/config_site.h'

The next step now is to run 'make dep' and 'make'.
6.根据上面的提示我们在终端运行make dep && make

最后到

rm output/samples-arm-unknown-linux-androideabi/stateless_proxy.o output/samples-arm-unknown-linux-androideabi/aviplay.o output/samples-arm-unknown-linux-androideabi/strerror.o output/samples-arm-unknown-linux-androideabi/sipecho.o output/samples-arm-unknown-linux-androideabi/resampleplay.o output/samples-arm-unknown-linux-androideabi/sipstateless.o output/samples-arm-unknown-linux-androideabi/simple_pjsua.o output/samples-arm-unknown-linux-androideabi/recfile.o output/samples-arm-unknown-linux-androideabi/icedemo.o output/samples-arm-unknown-linux-androideabi/clidemo.o output/samples-arm-unknown-linux-androideabi/httpdemo.o output/samples-arm-unknown-linux-androideabi/siprtp.o output/samples-arm-unknown-linux-androideabi/stateful_proxy.o output/samples-arm-unknown-linux-androideabi/tonegen.o output/samples-arm-unknown-linux-androideabi/level.o output/samples-arm-unknown-linux-androideabi/pcaputil.o output/samples-arm-unknown-linux-androideabi/pjsip-perf.o output/samples-arm-unknown-linux-androideabi/vid_streamutil.o output/samples-arm-unknown-linux-androideabi/streamutil.o output/samples-arm-unknown-linux-androideabi/auddemo.o output/samples-arm-unknown-linux-androideabi/playsine.o output/samples-arm-unknown-linux-androideabi/aectest.o output/samples-arm-unknown-linux-androideabi/jbsim.o output/samples-arm-unknown-linux-androideabi/stereotest.o output/samples-arm-unknown-linux-androideabi/playfile.o output/samples-arm-unknown-linux-androideabi/latency.o output/samples-arm-unknown-linux-androideabi/simpleua.o output/samples-arm-unknown-linux-androideabi/confsample.o output/samples-arm-unknown-linux-androideabi/mix.o output/samples-arm-unknown-linux-androideabi/encdec.o
make[2]: Leaving directory `/pjsip2.x/pjsip-apps/build'
make[1]: Leaving directory `/pjsip2.x/pjsip-apps/build'
编译成功。

7.然后到pjsip-apps/src/pjsua/android目录下面我们要编译android项目所需要的库,运行ndk-build,结果如下:

root@zhangjie:/pjsip2.x/pjsip-apps/src/pjsua/android# ndk-build
Invoking SWIG...
swig -c++ -o jni/pjsua_wrap.cpp -package org.pjsip.pjsua -outdir src/org/pjsip/pjsua -java jni/pjsua.i
Compile++ thumb  : pjsua <= pjsua_wrap.cpp
Compile++ thumb  : pjsua <= pjsua_app_callback.cpp
StaticLibrary  : libstdc++.a
SharedLibrary  : libpjsua.so
Install        : libpjsua.so => libs/armeabi/libpjsua.so

注意:

如果是编译pjsip的动态库,供java层调用,编译完静态库之后,还需要安装swig编译动态库和接口
需要swig 2.0.5以上的版本。ubuntu 12.04自带的swig是2.0.4,不符合要求,需要自行编译安装swig的新版本


你可能感兴趣的:(android,通讯开发,XMPP通讯工具开发)