-Objc其他链接器标志给出重复的符号错误

时间:2016-10-01 11:35:57

标签: ios objective-c xcode

我正在使用Unrar4iOS.Framework。它工作正常,但当我添加-Objc其他链接器标志。它给了我重复的错误。

    duplicate symbol __Z12CallbackProcjlll in:
    Library/Developer/Xcode/DerivedData/SARUnArchiveANY-fgljekydpkmvrlgapbahtfvvhsdl/Build/Intermediates/SARUnArchiveANY.build/Debug-iphonesimulator/SARUnArchiveANY.build/Objects-normal/x86_64/Unrar4iOS.o
    /My Project/SARUnArchiveANY-master/SARUnArchiveANY/vendor/Frameworks/Unrar4iOS.framework/Unrar4iOS(Unrar4iOS.o)
duplicate symbol _OBJC_IVAR_$_Unrar4iOS.header in:
    Library/Developer/Xcode/DerivedData/SARUnArchiveANY-fgljekydpkmvrlgapbahtfvvhsdl/Build/Intermediates/SARUnArchiveANY.build/Debug-iphonesimulator/SARUnArchiveANY.build/Objects-normal/x86_64/Unrar4iOS.o
    My Project/SARUnArchiveANY-master/SARUnArchiveANY/vendor/Frameworks/Unrar4iOS.framework/Unrar4iOS(Unrar4iOS.o)
duplicate symbol _OBJC_IVAR_$_Unrar4iOS.flags in:
    Library/Developer/Xcode/DerivedData/SARUnArchiveANY-fgljekydpkmvrlgapbahtfvvhsdl/Build/Intermediates/SARUnArchiveANY.build/Debug-iphonesimulator/SARUnArchiveANY.build/Objects-normal/x86_64/Unrar4iOS.o
    My Project/SARUnArchiveANY-master/SARUnArchiveANY/vendor/Frameworks/Unrar4iOS.framework/Unrar4iOS(Unrar4iOS.o)

我需要添加使用Objc标志来使用其他库。

1 个答案:

答案 0 :(得分:5)

如果要指定-all_load或-Objc标志,并且静态库在项目中具有相同的类符号名称,则在链接时间中会看到这些“重复符号”错误。

原因是什么?

  

此标志使链接器加载库中定义Objective-C类或类别的每个目标文件。虽然此选项通常会导致更大的可执行文件(由于加载了额外的对象代码)进入应用程序),它将允许成功创建包含现有类的类别的有效Objective-C静态库。   

来自Apple官方文档。

在你的项目中,现在,Unrar4iOS.o中的3个符号已经崩溃。

例如,在您的第一个重复的符号错误日志中,

__Z12CallbackProcjlll符号在中崩溃 (1)Library / Developer / Xcode / DerivedData / SARUnArchiveANY-fgljekydpkmvrlgapbahtfvvhsdl / Build / Intermediates / SARUnArchiveANY.build / Debug-iphonesimulator / SARUnArchiveANY.build / Objects-normal / x86_64 / Unrar4iOS.o

(2)/我的项目/ SARUnArchiveANY-master / SARUnArchiveany / vendor / Frameworks / Unrar4iOS.framework / Unrar4iOS(Unrar4iOS.o)

并且相同的模式将用于第二个和第三个重复符号。

duplicate symbol __Z12CallbackProcjlll in:
Library/Developer/Xcode/DerivedData/SARUnArchiveANY-fgljekydpkmvrlgapbahtfvvhsdl/Build/Intermediates/SARUnArchiveANY.build/Debug-iphonesimulator/SARUnArchiveANY.build/Objects-normal/x86_64/Unrar4iOS.o
/My Project/SARUnArchiveANY-master/SARUnArchiveANY/vendor/Frameworks/Unrar4iOS.framework/Unrar4iOS(Unrar4iOS.o)

duplicate symbol _OBJC_IVAR_$_Unrar4iOS.header in:
Library/Developer/Xcode/DerivedData/SARUnArchiveANY-fgljekydpkmvrlgapbahtfvvhsdl/Build/Intermediates/SARUnArchiveANY.build/Debug-iphonesimulator/SARUnArchiveANY.build/Objects-normal/x86_64/Unrar4iOS.o
My Project/SARUnArchiveANY-master/SARUnArchiveANY/vendor/Frameworks/Unrar4iOS.framework/Unrar4iOS(Unrar4iOS.o)

duplicate symbol _OBJC_IVAR_$_Unrar4iOS.flags in:
Library/Developer/Xcode/DerivedData/SARUnArchiveANY-fgljekydpkmvrlgapbahtfvvhsdl/Build/Intermediates/SARUnArchiveANY.build/Debug-iphonesimulator/SARUnArchiveANY.build/Objects-normal/x86_64/Unrar4iOS.o
My Project/SARUnArchiveANY-master/SARUnArchiveANY/vendor/Frameworks/Unrar4iOS.framework/Unrar4iOS(Unrar4iOS.o)

因此,要总结您的项目症状,现在,在您的项目中, Unrar4iOS.framework和SARUnArchiveANY库在以下三个重复符号中相互崩溃:Unrar4iOS目标文件。

另外,下面是SARUnArchiveANY git存储库的介绍 它已经指定SARUnArchiveANY库包含Unrar4iOS。

  

SARUnArchiveANY

     

一个非常有用的库,用于解压缩iOS的.zip,.rar,.7z文件。   简单地集成以下库:

     

<强> Unrar4iOS
  SSZipArchive
  LZMA SDK(7z)
  
来自https://github.com/saru2020/SARUnArchiveANY


为了解决这个问题,我推荐这个链接 http://atnan.com/blog/2012/01/12/avoiding-duplicate-symbol-errors-during-linking-by-removing-classes-from-static-libraries

你可以解决这个问题,因为我之前已经这样做了。