ios - 编译iOS的Sofia-SIP

标签 ios arm clang cross-compiling sofia-sip

我正在尝试为体系结构armv6armv7编译iOS的Sofia-SIP library,但是遇到了问题。下面是我在做什么。

export DEVROOT=/Applications/Xcode_4_6.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer    
export SDKROOT=$DEVROOT/SDKs/iPhoneOS6.1.sdk    
export CC=$SDKROOT/usr/bin/llvm-gcc-4.2    
export CFLAGS="-pipe -no-cpp-precomp -isysroot $SDKROOT -arch armv7"    
export LDFLAGS="-syslibroot $SDKROOT -arch armv7"    
export CPP=$SDKROOT/usr/bin/llvm-g++-4.2./configure --host=arm-apple-darwin10    
sudo ./configure --host=arm-apple-darwin10

结果
Password:    
configure: WARNING: if you wanted to set the --build type, don't use --host.
    If a cross compiler is detected then cross compile mode will be used    
checking build system type... x86_64-apple-darwin12.5.0    
checking host system type... arm-apple-darwin10    
checking target system type... arm-apple-darwin10    
checking cached information... ok    
checking for a BSD-compatible install... /usr/bin/install -c    
checking whether build environment is sane... yes    
checking for gawk... gawk    
checking whether make sets $(MAKE)... yes    
checking for arm-apple-darwin10-strip... no    
checking for strip... strip    
checking whether to enable maintainer-specific portions of Makefiles... no    
checking for style of include used by make... GNU    
checking for arm-apple-darwin10-gcc... no    
checking for gcc... gcc    
checking for arm-apple-darwin10-gcc... gcc    
checking whether the C compiler works... yes

问题

我希望脚本使用llvm-gcc编译器。但是相反,它正在寻找它找不到的arm-apple-darwin10-gcc,然后最终使用gcc编译器结束。

最佳答案

我为此进行了一个周末的战斗,赢得了战斗(在很多帮助下),并拥有以下返回社区的条件:

  • 关于 su_os_nw.c SCDynamicStore: function has been explicitly marked unavailable for iOS问题:

    我本来要放弃的,但注意到来自Restcomm reported success in integrating Sofia in their iOS SDK的一个名叫Antonis Tsakirids的人。
    然后,我去了他们的git仓库和had a look at their SDK

    在/ dependencies / sofia-sip / libsofia-sip-ua / su /中,我找到了罪魁祸首: su_os_nw.c

  • 他们优雅地更新
    #if defined (__APPLE_CC__)
    


    #if defined (__APPLE_CC__) && !defined(TARGET_OS_IPHONE)
    

    解决了...
  • …但是它不能单独解决它…因为since Xcode 7, Apple did some toolchain utilities shuffling显然是。
    Stuff不再位于“常规”位置,MishaBruckman的$ DEVROOT已过时。
    例如,我遇到有关找不到“ar”的错误。

  • export DEVROOT =“$(xcrun --sdk iphoneos --show-sdk-platform-path)/ Developer”
    映射到 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer

    但是,工具链实用程序(ld,ar,as,nm,ranlib以及全能的叮当声)已移至 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain / usr / bin。
    我加粗了应该映射到新$ DEVROOT的部分。

    希望这可以帮助某人挽救2个周末的生命...

    …最后,上面提到的两点不足以摆脱困境……编译的确完成了,我最初就把它保留了下来。

    但是,今天我想实际使用该库。创建了一个新项目,导入了库,点击了Build,……更多的痛苦……
    libsofia-sip-ua.a does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target for architecture armv7.
    

    起初我去了“说什么……?”
  • 关于在Xcode中设置内容的这个mumbo_jumbo是什么?我以old_school方式进行操作,在命令行中进行编译...
  • 您的意思是“从供应商那里获取更新的库” ...“供应商”是我,我正在构建库...
  • 反正这是什么奇怪的位码?

  • 在完成了关于位码的作业之后,我开始想知道Xcode的ENABLE_BITCODE背后隐藏着什么……原来是“意味着”将“-fembed-bitcode”标志传递给clang。

    总之,该行
    export CFLAGS="-arch ${ARM_ARCH} -mios-version-min=7 -pipe -no-cpp-precomp -isysroot ${SDKROOT} -I${SDKROOT}/usr/include/"
    

    成为
    export CFLAGS="-arch ${ARM_ARCH} -mios-version-min=7 -fembed-bitcode -pipe -no-cpp-precomp -isysroot ${SDKROOT} -I${SDKROOT}/usr/include/"
    

    使用新设置重建了Sofia,但是随后它开始抱怨说,即使主项目本身运行正常,它的SUB-LIBRARIES(例如libstun.a)也没有使用位代码进行编译。一个“使干净”摆脱了旧的垃圾,编译就可以了。将新产生的库导入到我的Xcode项目中,一切都还好。

    到此结束。在Anno Domini 2015中成功集成X集成了索非亚库的Xcode 7 / iOS9下的项目成功构建…

    ... aaaaand ...我仍未走出困境...

    我决定将 arm64 体系结构添加到我的项目后,Xcode再次开始抱怨Sofia:
    ignoring file libsofia-sip-ua.a, file was built for archive which is not the architecture being linked (arm64)
    Undefined symbols for architecture arm64
    

    很简单,我想:我将用 arm64 替换 armv7 :
    export ARM_ARCH="arm64”
    

    修改之后,灾难发生在./configure-ing期间:
    checking for gcc... /usr/bin/clang
    checking for gcc... (cached) /usr/bin/clang
    checking whether the C compiler works... no
    configure: error: in `/work/fromSourceforge/sofia-sip-1.12.11':
    configure: error: C compiler cannot create executables
    See `config.log' for more details
    

    第二天花了点时间找出问题所在(我再也无法进行./configure,甚至恢复为armv7)
  • 冲入堆栈溢出;没有解决方案帮助
  • 检查广告重新检查了系统上的每条路径...我很惊讶地发现,在整个macosx中可以在3-4个地方找到clang和gcc,但我离题了...
  • 尝试重新安装Xcode开发人员工具
  • 最终重新安装了Xcode本身...

  • ...没有任何帮助。

    一位鹰眼的同事发现了问题所在:

    导出ARM_ARCH = “arm64”

    最后一个引号与第一个引号“不相同”。第一个引号是“正确种类的引号”。
    即使我没有亲手接触第二个,在将v7转换为64时,TextEdit还是自行更改了所有内容。显然,这是“一项功能”,称为SmartQuotes。顺便说一下,我无法禁用它。
    提示:切勿再次使用TextEdit来编辑.bash_profile文件。

    最后,我发现自己沉迷于64位版本的索非亚。将其插入我的Xcode项目aaaaaaand ....
    ignoring file libsofia-sip-ua.a, file was built for archive which is not the architecture being linked (armv7)
    Undefined symbols for architecture armv7
    

    嗯...如果我将其构建为32位,则抱怨缺少64位...如果我将其构建为64位,则抱怨为缺少32位...

    事实证明,有一种方法可以将多个库融合为一个“胖”库。
    该实用程序称为lipo,您可以使用以下形式:
    lipo -create "path_to_lib_1" "path_to_lib2" -output "path_to_desired_name_of_the_merged_library"
    

    因此:在iOS下,SIP与Sofia一起作为一个单独的库同时执行32位和64位...
    ew ...

    ..... aaaaaaaa,我们还没有完成...!

    问题:尝试执行任何操作(例如,REGISTER)会立即导致503 DNS错误
    原因:Sofia在etc / resolv.conf中搜索名称服务器列表
    显然,这是iOS,它不存在,或者在应用程序沙箱外部。
    解决方案:这是第二个人Antonis Tsakiridis救了我的屁股。恭敬的鞠躬。
    首先,他谈论what he intends to do
    其次,他显示了he has actually done

    但是,该解决方案公开了一个新的...

    问题:_res_9_init-在重新编译Sofia时,体系结构的未定义符号(armv7或arm64,取决于我碰巧为ARM_ARCH设置的内容)
    原因:我不知道。我只能从解决方案中推断出,需要告知链接程序“resolv”库
    解决方案:在两个地方添加了-lresolv:
  • LDFLAGS(在.bash_profile文件中)
  • Xcode“应用程序”项目中的
  • (练习库的项目);目标--->链接---> OtherLinkerFlags

  • 就像以前一样,尽管以上内容解决了它要解决的问题,但它也使我们前进到下一个...

    问题:没有发生在#IOS_BUILD下的条件代码执行(AT的第一个问题的解决方案的一部分)。仍然收到503 DNS错误...
    原因:实际上,我无法确定我的生活。当然,在我自己的代码中的任何地方定义它都是无效的,因为Sofia应该是已经编译的依赖项;在预处理器处理她的代码时,我们再也没有机会了。
    解决方案:我用一个名为IOS_BUILD的环境变量替换了IOS_BUID #define,该变量的值是...好... IOS_BUILD。我在这里告诉Xcode(我试图使用“define”一词以避免混淆)
    产品--->方案---> EditScheme --->参数---> EnvironmentVariables。
    在索非亚,我只是将#Ifdef IOS_BUILD替换为对getenv()和strcmp()的调用。

    毕竟,瞧……注册发生了……
    另外,由于索非亚的智能“解析器”,每次将iPhone连接到另一个Wi-Fi时,DNS设置都能正确检测到。

    关于ios - 编译iOS的Sofia-SIP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23647452/

    相关文章:

    c++ - ARM 设备的交叉编译库

    linux - OpenCV Cmake 无法找到 ffmpeg 库

    ios - 如何使用 ARKit 将 SCNNode 的方向更改为相机

    ios - Swift-使用委托(delegate)在 tableView 上显示

    ios - 如何在IOS中模拟陀螺仪反馈?

    arrays - C++ clang 数组比 clang 向量和 gcc 向量和数组快得多

    c++ - 如何使用 ms code gen 添加/bigobj 切换到 clang?

    c# - Xamarin Forms 图像大小不匹配

    linux - arm linux 系统调用中 vector_swi() 中使用的堆栈指针是如何初始化的?

    objective-c - 来自参数的可打印类型字符串