在Mac上为iOS交叉编译osip2和eXosip2

写在最前面:ios

若是没有必须选择eXosip的理由,那么它毫不应该是你的第一选择,本人更倾向于Pjsip,不管是架构,仍是其详实的文档支持,亦或是多个开源参考实例,都能让你更快的学习运用它。架构

-----------------------------------------------------------------------------------------------------app

首先打开终端,进入osip2或者eXoisp的根目录,而后进行详细配置以生成makefile。学习

具体的参数,能够经过$ ./configure --help 查看“详细”说明google

iPhone模拟器:spa

1.osip2code

./configure CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang CFLAGS="-O2 -m32 -mios-simulator-version-min=5.0 -DPJ_SDK_NAME="\"iPhoneSimulator7.1.sdk\"" -arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.1.sdk" --host=arm-apple-darwin9 --target=arm-apple-darwin9 --prefix=/Users/noone/Documents/siplibs/i386orm


2.eXosip2ip

$./configure CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang CFLAGS="-O2 -m32 -mios-simulator-version-min=5.0 -DPJ_SDK_NAME="\"iPhoneSimulator7.1.sdk\"" -arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.1.sdk" LDFLAGS=" -framework MobileCoreServices -framework CFNetwork -framework CoreFoundation" --disable-openssl --host=arm-apple-darwin9 --target=arm-apple-darwin9 --prefix=/Users/noone/Documents/siplibs/i386ssl


iPhone真机:

1.osip2

./configure CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang CFLAGS="-DPJ_SDK_NAME="\"iPhoneOS7.1.sdk\"" -arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk" --host=arm-apple-darwin9 --target=arm-apple-darwin9 --prefix=/Users/noone/Documents/siplibs/arm


二、eXosip2

./configure CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang CFLAGS="-DPJ_SDK_NAME="\"iPhoneOS7.1.sdk\"" -arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk" LDFLAGS=" -framework MobileCoreServices -framework CFNetwork -framework CoreFoundation" --disable-openssl --host=arm-apple-darwin9 --target=arm-apple-darwin9 --prefix=/Users/noone/Documents/siplibs/arm

开始编译:

通过上面的配置,生成make文件后,在执行:

$ make

$ make install

 就能够在--prefix指定的输出目录找到编译好的库文件。

合并:

通过前面的工做会分别生成适合模拟器和真机的2种库,经过下面的命令能够进行合并,更多细节请google。

lipo -create /Users/noone/Desktop/arm/lib/libeXosip2.a /Users/noone/Desktop/i386/lib/libeXosip2.a -output /Users/noone/Desktop/libs/libeXosip2_for_ios.a

最后:

在引入项目的时候注意:在引入前面指定的framework的同时,还须要引入“libresolv.9.dylib”这个eXosip的依赖库,方可编译经过。

相关文章
相关标签/搜索