Xcode 4.4.1中的non_lazy_ptr的iOS SDK 5.1链接器错误

(我把这个问题发贴到了VideoLAN论坛,但是还没有接手,我知道这个社区不会让我失望.)

我正在为iOS构建MobileVLC项目.我已经通过命令行流程来构建项目,经过了http://forum.videolan.org/viewtopic.php?f=12&t=103331http://forum.videolan.org/viewtopic.php?f=12&t=103271中描述的几个调整之后,构建脚本几乎完成了.当它尝试获取Xcode来构建最终项目时,它会出错.所以我加载到Xcode并尝试构建,我可以看到错误,这里是我使用-v链接器标志时得到的:

Ld /Users/bp/Library/Developer/Xcode/DerivedData/MobileVLC-ctcjnpeqzuhulxcmjlhrjnyzpzil/Build/Products/Debug-iphoneos/VLC.app/VLC normal armv7
    cd /Users/bp/Desktop/vlc/MobileVLC
    setenv IPHONEOS_DEPLOYMENT_TARGET 5.1
    setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk -L/Users/bp/Library/Developer/Xcode/DerivedData/MobileVLC-ctcjnpeqzuhulxcmjlhrjnyzpzil/Build/Products/Debug-iphoneos -L/Users/bp/Desktop/vlc/MobileVLC/External/MobileVLCKit -L/Users/bp/Desktop/vlc/MobileVLC/External/MediaLibraryKit -F/Users/bp/Library/Developer/Xcode/DerivedData/MobileVLC-ctcjnpeqzuhulxcmjlhrjnyzpzil/Build/Products/Debug-iphoneos -filelist /Users/bp/Library/Developer/Xcode/DerivedData/MobileVLC-ctcjnpeqzuhulxcmjlhrjnyzpzil/Build/Intermediates/MobileVLC.build/Debug-iphoneos/MobileVLC.build/Objects-normal/armv7/VLC.LinkFileList -dead_strip -Wl,-no_pie,-v -fobjc-link-runtime -miphoneos-version-min=5.1 -framework Foundation -framework UIKit -framework CoreGraphics -framework OpenGLES -framework AudioToolbox -framework QuartzCore -liconv -lz /Users/bp/Library/Developer/Xcode/DerivedData/MobileVLC-ctcjnpeqzuhulxcmjlhrjnyzpzil/Build/Products/Debug-iphoneos/libMobileMediaLibraryKit.a -lsqlite3 -lstdc++.6 -lbz2 -lxml2 -framework CoreData -framework CoreText -framework MediaPlayer /Users/bp/Library/Developer/Xcode/DerivedData/MobileVLC-ctcjnpeqzuhulxcmjlhrjnyzpzil/Build/Products/Debug-iphoneos/libMobileVLCKit.a -o /Users/bp/Library/Developer/Xcode/DerivedData/MobileVLC-ctcjnpeqzuhulxcmjlhrjnyzpzil/Build/Products/Debug-iphoneos/VLC.app/VLC

@(#)PROGRAM:ld  PROJECT:ld64-133.3
configured to support archs: armv6 armv7 i386 x86_64
Library search paths:
   /Users/bp/Library/Developer/Xcode/DerivedData/MobileVLC-ctcjnpeqzuhulxcmjlhrjnyzpzil/Build/Products/Debug-iphoneos
   /Users/bp/Desktop/vlc/MobileVLC/External/MobileVLCKit
   /Users/bp/Desktop/vlc/MobileVLC/External/MediaLibraryKit
   /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/usr/lib
Framework search paths:
   /Users/bp/Library/Developer/Xcode/DerivedData/MobileVLC-ctcjnpeqzuhulxcmjlhrjnyzpzil/Build/Products/Debug-iphoneos
   /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/System/Library/Frameworks/
LLVM version 3.1svn,from Apple Clang 4.0 (build 421.0.60)
ld: 'non_lazy_ptr' in /Users/bp/Library/Developer/Xcode/DerivedData/MobileVLC-ctcjnpeqzuhulxcmjlhrjnyzpzil/Build/Products/Debug-iphoneos/libMobileVLCKit.a(libdeinterlace_plugin_la-deinterlace.o) contains undefined reference for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)

据我所知,libMobileVLCKit.a文件被链接到MobileVLC项目中,所以我不确定下一步要查找什么,因为我找不到任何代码中的任何地方的任何引用non_lazy_ptr,框架引用都看起来不错.即使你不知道解决方案,任何关于在哪里寻找问题的想法将不胜感激.谢谢.

编辑:这是一个屏幕截图,显示MobileVLC项目的“构建阶段”选项卡中的所有内容.

编辑2:我在VideoLAN论坛上的贴子已经得到了一些“我也是”的回复,以及与另一个用户非常相似的错误.最后一行是错误信息:

ld: '_AmplifyFloat' in /Users/**/MobileVLC/ImportedSources/VLCKit/build/Release-iphoneos/libMobileVLCKit.a(libvolume_neon_plugin_la-volume.o) contains undefined reference for architecture armv7

这是VideoLAN论坛上的贴子:http://forum.videolan.org/viewtopic.php?f=12&t=103433

编辑3:我从VideoLAN的git存储库中获取了一个新的源代码,并通过user1071136提供的答案,最后得到了与他们所得到的完全相同的错误.

我在Stack Overflow上发现了一个类似的错误,表明解决方案是检查,以确保Apple LLVC编译器4.0 – 代码生成构建设置中的Generate Position-Dependent Code选项被设置为No.但正如试图获得VLC在iOS上运行,这是一个死胡同,因为构建设置已经设置为否.

这是一个链接到这个问题和答案:(null): In section __TEXT,__text reloc 3: section For Address(0x7C6C) address not in any section for architecture armv7

解决方法

我没有能够成功构建它,但我已经克服了一些可能有用的障碍.

障碍1:ARM Thumb2

总结:即使广告作为完全支持的拇指,它似乎是苹果提供的clang,以及LLVM 3.2的一个无法翻译显示在libav的ARM汇编代码中的一些有效的Thumb指令.

详细信息:libav(ffmpeg的一个fork)在汇编器中实现了一些功能.当构建iOS时,将使用MobileVLC / ImportedSources / vlc / contrib / iPhoneOS / ffmpeg / libavcodec / arm中的文件.第一个可能遇到的编译错误是类似的

libavcodec/arm/aacpsdsp_neon.S:132:21: error: invalid operand for instruction
        add r4,r0,#38*64*4

根据ARM Thumb2’s reference,上述指令是有效的ADD {S} Rd,Rn,< Operand2>指令,其中< Operand2>拇指模式是“通过将8位值左移任意位形成的32位常数”.由于#38 * 64 * 4等于38左移8次,所以cl应该接受它.似乎cl声不会识别它是可能的,因此试图将该指令解释为ADD Rd,#< imm12>一个,即时争论必须小于4096.

如果对这个问题有更多信心的人可以相关 – 这是cl a吗?

解决方法:如http://forum.videolan.org/viewtopic.php?f=12&t=103271所示,配置ffmpeg(实际上是libav)时,应该禁用拇指.

障碍2:libtool不能推断标签

总结:MobileVLC的libtool被配置为推断C编译,它期望调用clang.当构建系统调用gas-preprocessor.pl xcrun clang时,libtool会引发错误.

详细信息:MobileVLC在MobileVLC / ImportedSources / vlc / build-ios-OS上配置一个libtool(它只是一个bash脚本)的副本.在第1681行,函数func_infer_tag负责推断标签.对于出现在第38行定义的变量$available_tags中的每个标签,都会搜索libtool本身的标签配置部分.例如,CXX(= C)标签配置从第9258行开始.从第9271行可以看出,C编译期望的编译器命令是xcrun clang.

构建系统调用libtool –mode = compile gas-preprocessor.pl xcrun clang …,因为xcrun clang不在命令前缀,所以不能推断C模式. (gas-preprocessor.pl将GNU汇编程序转换为Apple汇编程序可以使用的东西)

解决方法:如http://forum.videolan.org/viewtopic.php?f=12&t=103331所述,可以修改MobileVLC / ImportedSources / vlc / modules / video_filter / Modules.am以强制libtool推断C编译.如果它不适合你,就像它不适合我,你可以自己调用libtool.

cd进入MobileVLC / ImportedSources / vlc / build-ios-OS / modules / video_filter;键入make应该会导致出现错误.键入make V = 1也将显示正在执行的命令.它将从source =’deinterlace / merge_arm.S’开始.您现在可以将其复制并手动调用,在../../libtool之后添加–tag = CC.

障碍3:CopyStringsFile

总结:构建MobileVLC失败,出现错误,

The following build commands failed:
    CopyStringsFile build/Release-iphoneos/VLC.app/pl.lproj/Localizable.strings Resources/pl.lproj/Localizable.strings

详细信息:违规文件MobileVLC / Resources / pl.lproj / Localizable.strings是缺少字节顺序(BOM)的UTF-16-LE文件,由于某些原因而使Xcode混淆.

解决办法:cd进入MobileVLC / Resources / pl.lproj /并执行

mv -n Localizable.strings Localizable.strings.backup && python -c "import sys; sys.stdout.write(chr(0xFF)+chr(0xFE))" > Localizable.strings && cat Localizable.strings.backup >> Localizable.strings

这会将BOM添加到文件的开头.

障碍4:non_lazy_ptr AmplifyFloat

摘要:此错误应为:“链接器ld的内部数据结构具有非延迟指针,其中包含无法找到的符号的地址”.找不到缺少的符号,因为它们没有加上下划线.

细节:这显然是一个耻辱,ld不会沉迷于我们知道究竟究竟找不到什么,但我们不在这里.

考虑以下简单的bla.c文件,

int bla();
int foo() { return bla(); }

编译这个文件(clang -c bla.c)然后列出它的符号(nm bla.o)显示链接器期望一些其他编译单元提供符号_bla(注意下划线).下划线可能被添加到表示bla应该在C调用约定中被调用.当在汇编文件中定义bla时出现问题;汇编器不添加下划线,导致bla符号,导致链接失败.

一个有趣的细节是,这种行为与Linux不同,下划线不会添加到符号名称中,这可能有助于解决VLC开发人员的注意力.然而,据我所知,强调的行为出现在MinGW中,所以解决方案可能类似.

解决方法:即使是临时的,最简单的解决方案是使用符号别名列表.创建一个具有以下内容的文件符号alias.txt,

merge16_arm_neon _merge16_arm_neon
merge8_arm_neon _merge8_arm_neon
amplify_float_arm_neon _amplify_float_arm_neon

根据标志和配置,该文件是足够的这对我来说足够了.在MobileVLC /目录中打开MobileVLC.xcodeproj.这应该是Xung Xcode.在项目设置中,选择MobileVLC目标,然后选择“构建设置”.在其他链接器标志中,添加

-Wl,-alias_list
-Wl,<absoluate-path-to-symbol_aliases.txt>

保存并构建.恭喜.你现在已经到达了障碍我不知道如何克服:)

障碍5:地址不在任何部分

摘要:链接器出现隐秘错误

ld: in section __TEXT,__text reloc 13: sectionForAddress(0xE142) address not in any section for architecture armv7

我对链接不够熟悉,弄清楚出了什么问题,但我猜想这一切都归结为汇编器编写的代码.

相关文章

当我们远离最新的 iOS 16 更新版本时,我们听到了困扰 Apple...
欧版/美版 特别说一下,美版选错了 可能会永久丧失4G,不过只...
一般在接外包的时候, 通常第三方需要安装你的app进行测...
前言为了让更多的人永远记住12月13日,各大厂都在这一天将应...