为所有体系结构编译PJSIP 2.5库

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了为所有体系结构编译PJSIP 2.5库相关的知识,希望对你有一定的参考价值。

要为iPhone设备编译PJSIP库,我正在使用此代码

make distclean && make clean
ARCH='-arch arm64' ./configure-iphone --enable-opus-codec
make dep
make

此代码允许我仅为单一架构安装我的应用程序。为所有架构(armv7,armv7s,arm64,i386,x86_64)编译pjsip,我可以使用哪个命令或工具

答案

为所有设备编译的步骤。

  1. 分别编译所有设备
  2. 与lipo合并

例如。

-create /libsrtp-arm64-apple-darwin_ios.a /libsrtp-i386-apple-darwin_ios.a -output output_file_name

然后使用output_file_name.a作为所有设备和模拟器的通用库

检查支持的架构:output_file_name.a

lipo -info name_of_static_lib

output : /libsrtp-universal-apple-darwin_ios.a are: armv7 armv7s i386 x86_64 arm64

Compile PJSIP 2.5 Library for all archietectures

谢谢

另一答案
--- One Way to build PJSIP libraries --- test with pjsip 2.6

//Updated for XCode 8. 

Building PJSIP
$ cd /Users/ravimalviya/Developer/Dev2/trunk

//If you want to specify the minimum supported iOS version
//export MIN_IOS="-miphoneos-version-min=8.0"

Compile Library and Build For Default iPhone 4 use armv7 architecture
$ ./configure-iphone && make dep && make clean && make

Build For iPhone 5, use armv7s architecture
$ ARCH='-arch armv7s' ./configure-iphone && make dep && make clean && make

Build For iPhone 5s, use arm64 architecture
$ ARCH='-arch arm64' ./configure-iphone && make dep && make clean && make

Build For Simulator, use i386 architecture
export DEVPATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer
ARCH="-arch i386" CFLAGS="-O2 -m32 -mios-simulator-version-min=5.0" LDFLAGS="-O2 -m32 -mios-simulator-version-min=5.0" ./configure-iphone
make dep && make clean && make

Build For Simulator, use x86_64 architecture
export DEVPATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer
ARCH="-arch x86_64" CFLAGS="-O2 -m32 -mios-simulator-version-min=5.0" LDFLAGS="-O2 -m32 -mios-simulator-version-min=5.0" ./configure-iphone
make dep && make clean && make

The compilation result
pjlib/lib       
pjlib-util/lib
pjmedia/lib
pjsip/lib
pjnath/lib
third_party/lib
Note add into project..

Combine resulting archtecture(arm64,armv7,armv7s,i386, x86_64) supported library .a file.

//goto directory where you collect all build library. create folder name arm64, armv7s, armv7, i386, x86_64 and put all library respectivly. each having only one arch supported library file.
//rename file in all these 5 folders it's a easy way to make universal library.
//Also create folder named unified where all unversal library will create.

$ export LIB_NAME="libg7221codec.a"
$ lipo -arch armv7 armv7/$LIB_NAME -arch armv7s armv7s/$LIB_NAME -arch arm64 arm64/$LIB_NAME -arch i386 i386/$LIB_NAME -arch x86_64 x86_64/$LIB_NAME -create -output unified/$LIB_NAME

//-arch armv7s armv7s/$LIB_NAME means support armv7s get library from directory armv7s/$LIB_NAME and $LIB_NAME file name that only support armv7s.
//-arch arm64 arm64/$LIB_NAME ............
//-arch armv7 armv7/$LIB_NAME ............
//-arch i386 i386/$LIB_NAME ..............
//-arch x86_64 x86_64/$LIB_NAME ..............
//unified/$LIB_NAME is directory where unversal library will build using lips. with same name $LIB_NAME that export. do it same.

//check which arch you lib is supporting
xcrun -sdk iphoneos lipo -info unified/$LIB_NAME

$ export LIB_NAME="libgsmcodec.a"
$ lipo -arch armv7 armv7/$LIB_NAME -arch armv7s armv7s/$LIB_NAME -arch arm64 arm64/$LIB_NAME -arch i386 i386/$LIB_NAME -arch x86_64 x86_64/$LIB_NAME -create -output unified/$LIB_NAME
$ export LIB_NAME="libilbccodec.a"
$ .....same as above in lipo......
$ export LIB_NAME="libpj.a"
$ .....same as above in lipo......
$ export LIB_NAME="libpjlib-util.a"
$ .....same as above in lipo......
$ export LIB_NAME="libpjmedia-audiodev.a"
$ .....same as above in lipo......
$ export LIB_NAME="libpjmedia-codec.a"
$ .....same as above in lipo......
$ export LIB_NAME="libpjmedia-videodev.a"
$ .....same as above in lipo......
$ export LIB_NAME="libpjmedia.a"
$ .....same as above in lipo......
$ export LIB_NAME="libpjnath.a"
$ .....same as above in lipo......
$ export LIB_NAME="libpjsdp.a"
$ .....same as above in lipo......
$ export LIB_NAME="libpjsip-simple.a"
$ .....same as above in lipo......
$ export LIB_NAME="libpjsip-ua.a"
$ .....same as above in lipo......
$ export LIB_NAME="libpjsip.a"
$ .....same as above in lipo......
$ export LIB_NAME="libpjsua.a"
$ .....same as above in lipo......
$ export LIB_NAME="libpjsua.a"
$ .....same as above in lipo......
$ export LIB_NAME="libpjsua2.a"
$ .....same as above in lipo......
$ export LIB_NAME="libresample.a"
$ .....same as above in lipo......
$ export LIB_NAME="libspeex.a"
$ .....same as above in lipo......
$ export LIB_NAME="libsrtp.a"
$ .....same as above in lipo......
$ export LIB_NAME="libyuv.a"
$ lipo -arch armv7 armv7/$LIB_NAME -arch armv7s armv7s/$LIB_NAME -arch arm64 arm64/$LIB_NAME -arch i386 i386/$LIB_NAME -arch x86_64 x86_64/$LIB_NAME -create -output unified/$LIB_NAME

Note: Unversal libraries you can add into your project and also mention in library search path.

//In order to use the pjsip libraries, we need to include folder that ahve header files that access .a files. Naturally, the header files are located in:
pjlib/include
pjlib-util/include
pjmedia/include
pjnath/include
pjsip/include

Note: do't add into project..buz you can not import like import <pjsip-lib/pjsip.h>
so just place these folder into project directory where ever you want but mention in header search path.

Enjoy (:)
另一答案

我们写了一个cocoapod,它将创建一个可以包含在项目中的静态库。目前,您只能在Objective C cocoapod环境中使用它。我们正在开发一个版本,它将创建一个动态库,以便它可以与Swift一起使用。

请查看:

https://github.com/VoIPGRID/Vialer-pjsip-iOS

我们制作了一个开源包装器,可以更轻松地将PJSIP集成到您的iOS项目中:

https://github.com/VoIPGRID/VialerSIPLib

另一答案

enter image description here

像发布这样的合并

lipo -create / My Project / pjsip-universal / x86_64 / libgsmcodec-x86_64-apple-darwin_ios.a / My Project / pjsip-universal / i386 / libgsmcodec-i386-apple-darwin_ios.a / My Project / pjsip- universal / armv7s / libgsmcodec-armv7s-apple-darwin_ios.a / My Project / pjsip-universal / armv7 / libgsmcodec-armv7-apple-darwin_ios.a / My Project / pjsip-universal / arm64 / libgsmcodec-arm64-apple- darwin_ios.a -output / My Project / pjsip-universal / universal / libgsmcodec-universal-apple-darwin_ios.a

最后测试一下

lipo -info / My Project / pjsip-universal / libgsmcodec-universal-apple-darwin_ios.a

输出:胖文件中的体系结构:/ My Project / pjsip-universal / libgsmcodec-universal-apple-darwin_ios.a是:i386 armv7s armv7 x86_64 arm64

生成通用体系结构后:

点击此链接,在此链接中添加项目

将头文件添加到项目中

how to add in project

希望这会帮助你。

另一答案

你可以在GitHub上查看this项目,它的作者在为所有架构构建pjsip方面做得很好,他甚至提供了podspec以便于CocoaPods集成。

另一答案

我正在使用这个脚本为我的archs构建pjsip。

我在pjsip根文件夹中运行它,它创建一个包含结果库的uni文件夹,然后我将其链接/添加到我的项目中。

#!/bin/bash

ARCHS="armv7 armv7s arm64"
mkdir -p uni

echo "Compiling..."
for arch in $ARCHS
do
  echo $arch
  echo "=================================="
  echo
  ARCH="-arch $arch" ./configure-iphone &&a

以上是关于为所有体系结构编译PJSIP 2.5库的主要内容,如果未能解决你的问题,请参考以下文章

如何构建和使用PJSIP用于不同于armeabi的架构?

ubuntu下PjSip2.10编译 for android

为 iOS 4.0 编译 pjsip

使用 pjsip 代码独立开发

尝试在 Xcode 上运行时 PJSIP 出错

使用pjsip传输已经编码的视频,源码在github