簡體   English   中英

Xcode 4.4.1中non_lazy_ptr的iOS SDK 5.1鏈接器錯誤

[英]iOS SDK 5.1 linker error for non_lazy_ptr in Xcode 4.4.1

(我把這個問題發布到VideoLAN論壇,但還沒有接受者。我知道SO社區不會讓我失望。)

我正在嘗試為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項目的Build Phases選項卡中的所有內容。

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 compiler 4.0 - Code Generation構建設置中的Generate Position-Dependent Code選項設置為否。但是通常嘗試獲取VLC在iOS上運行,這也是一個死胡同,因為構建設置已經設置為No。

以下是該問題和答案的鏈接: (null):在__TEXT部分,__ text reloc 3:部分地址(0x7C6C)地址不在任何部分中,用於體系結構armv7

我無法成功構建它,但我已經克服了一些可能有用的障礙。

障礙1:ARM Thumb2

簡介 :盡管廣告宣傳為完全支持thumb ,但它似乎是Apple提供的clang ,而LLVM 3.2無法翻譯出現在libav的ARM匯編代碼中的一些有效的thumb指令。

詳細信息libavffmpeg一個分支)在匯編程序中實現了一些功能。 在為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的參考 ,上面的指令是有效的ADD{S} Rd, Rn, <Operand2>指令,其中thumb模式下的<Operand2>是“32位常數,通過左移8位值形成任意數量的比特“。 由於#38*64*4等於38左移8次,所以clang應該接受它。 似乎clang不會認識到它是可能的,因此試圖將指令解釋為ADD Rd, Rn, #<imm12> one,其立即參數必須小於4096。

如果對這個問題更有信心的人可以聯系到 - 這是一個clang的錯誤嗎?

解決方法 :如http://forum.videolan.org/viewtopic.php?f=12&t=103271中所述 ,配置ffmpeg (實際上是libav )時應禁用thumb

障礙2:libtool無法推斷標簽

簡介MobileVLClibtool被配置為推斷C ++編譯,它需要調用clang++ 當構建系統調用gas-preprocessor.pl xcrun clanglibtool會拋出錯誤。

詳細信息MobileVLCMobileVLC/ImportedSources/vlc/build-ios-OS配置libtool (這只是一個bash腳本)的MobileVLC/ImportedSources/vlc/build-ios-OS 在第1681行,函數func_infer_tag負責推斷標簽。 對於出現在第38行定義的變量$available_tags中的每個標記,將搜索libtool本身的標記配置部分。 例如,CXX(= C ++)標簽配置從第9258行開始。從第9271行可以看出,C ++編譯xcrun clang++的編譯器命令是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' o… 您現在可以復制並手動調用它,在../../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無法找到的地址”。 找不到缺少的符號,因為它們沒有下划線前綴。

詳細說明 :這顯然是一個恥辱, ld不會隨究竟它無法找到知識放縱我們,但我們不是在這里咆哮。

考慮以下簡單的bla.c文件,

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

編譯這個文件( clang -c bla.c )然后列出它的符號( nm bla.o )會發現鏈接器需要一些其他編譯單元來提供符號_bla (注意下划線)。 可能會添加下划線表示應該在C調用約定中調用bla bla在匯編程序文件中定義時會出現問題; 匯編程序不添加下划線,導致bla符號,導致鏈接失敗。

一個有趣的細節是,這種行為與Linux不同,其中下划線沒有添加到符號名稱,這可能有助於問題擺脫VLC的開發人員的注意。 盡管如此,據我所知,MinGW中出現了強調行為,因此解決方案可能類似。

解決方法 :即使是臨時的,最簡單的解決方案是使用符號別名列表。 使用以下內容創建文件symbol-alias.txt

merge16_arm_neon _merge16_arm_neon
merge8_arm_neon _merge8_arm_neon
amplify_float_arm_neon _amplify_float_arm_neon

這個文件足夠取決於標志和配置; 不過,這對我來說已經足夠了。 MobileVLC/目錄中鍵入open MobileVLC.xcodeproj 這應該是laungh Xcode。 在項目設置中,選擇MobileVLC目標,然后選擇“ Build Settings Other Linker Flags ,添加

-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

我不太熟悉鏈接以找出錯誤,但我想這一切都歸結為用匯編語言編寫的代碼。

看你需要目標依賴項libMobileVLCKit

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM