ld: 8个重复的建筑符号i386。

时间:2021-03-06 09:39:25

I gone through question already asked on forum. Getting error as below

我在论坛上已经问过问题了。得到错误如下

ld: 8 duplicate symbols for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

More error description is below

下面是更多的错误描述

ld: warning: directory not found for option '-L/Users/Documents/Sprint1/iPhone/MyApplication/MyApplication/lib/lib'
ld: warning: directory not found for option '-Lrestkit'
ld: warning: ignoring file /Users/Documents/Sprint1/iPhone/MyApplication/MyApplication/lib/lib restkit/libRestKit.a, missing required architecture i386 in file /Users/Documents/Sprint1/iPhone/MyApplication/MyApplication/lib/lib restkit/libRestKit.a (2 slices)
duplicate symbol _OBJC_IVAR_$_Reachability.reachabilityRef in:
    /Users/Library/Developer/Xcode/DerivedData/MyApplication-bchgbqjzuwjzbcbnhwyihhatsoyw/Build/Intermediates/MyApplication.build/Debug-iphonesimulator/MyApplication.build/Objects-normal/i386/Reachability.o
    /Users/Library/Developer/Xcode/DerivedData/MyApplication-bchgbqjzuwjzbcbnhwyihhatsoyw/Build/Products/Debug-iphonesimulator/libPOSNirvanaUtils.a(Reachability.o)
duplicate symbol _kReachabilityChangedNotification in:
    /Users/Library/Developer/Xcode/DerivedData/MyApplication-bchgbqjzuwjzbcbnhwyihhatsoyw/Build/Intermediates/MyApplication.build/Debug-iphonesimulator/MyApplication.build/Objects-normal/i386/Reachability.o
    /Users/Library/Developer/Xcode/DerivedData/MyApplication-bchgbqjzuwjzbcbnhwyihhatsoyw/Build/Products/Debug-iphonesimulator/libPOSNirvanaUtils.a(Reachability.o)
duplicate symbol _kInternetConnection in:
    /Users/Library/Developer/Xcode/DerivedData/MyApplication-bchgbqjzuwjzbcbnhwyihhatsoyw/Build/Intermediates/MyApplication.build/Debug-iphonesimulator/MyApplication.build/Objects-normal/i386/Reachability.o
    /Users/Library/Developer/Xcode/DerivedData/MyApplication-bchgbqjzuwjzbcbnhwyihhatsoyw/Build/Products/Debug-iphonesimulator/libPOSNirvanaUtils.a(Reachability.o)
duplicate symbol _kLocalWiFiConnection in:
    /Users/Library/Developer/Xcode/DerivedData/MyApplication-bchgbqjzuwjzbcbnhwyihhatsoyw/Build/Intermediates/MyApplication.build/Debug-iphonesimulator/MyApplication.build/Objects-normal/i386/Reachability.o
    /Users/Library/Developer/Xcode/DerivedData/MyApplication-bchgbqjzuwjzbcbnhwyihhatsoyw/Build/Products/Debug-iphonesimulator/libPOSNirvanaUtils.a(Reachability.o)
duplicate symbol _OBJC_IVAR_$_Reachability.key_ in:
    /Users/Library/Developer/Xcode/DerivedData/MyApplication-bchgbqjzuwjzbcbnhwyihhatsoyw/Build/Intermediates/MyApplication.build/Debug-iphonesimulator/MyApplication.build/Objects-normal/i386/Reachability.o
    /Users/Library/Developer/Xcode/DerivedData/MyApplication-bchgbqjzuwjzbcbnhwyihhatsoyw/Build/Products/Debug-iphonesimulator/libPOSNirvanaUtils.a(Reachability.o)
duplicate symbol _OBJC_CLASS_$_Reachability in:
    /Users/Library/Developer/Xcode/DerivedData/MyApplication-bchgbqjzuwjzbcbnhwyihhatsoyw/Build/Intermediates/MyApplication.build/Debug-iphonesimulator/MyApplication.build/Objects-normal/i386/Reachability.o
    /Users/Library/Developer/Xcode/DerivedData/MyApplication-bchgbqjzuwjzbcbnhwyihhatsoyw/Build/Products/Debug-iphonesimulator/libPOSNirvanaUtils.a(Reachability.o)
duplicate symbol _OBJC_METACLASS_$_Reachability in:
    /Users/Library/Developer/Xcode/DerivedData/MyApplication-bchgbqjzuwjzbcbnhwyihhatsoyw/Build/Intermediates/MyApplication.build/Debug-iphonesimulator/MyApplication.build/Objects-normal/i386/Reachability.o
    /Users/Library/Developer/Xcode/DerivedData/MyApplication-bchgbqjzuwjzbcbnhwyihhatsoyw/Build/Products/Debug-iphonesimulator/libPOSNirvanaUtils.a(Reachability.o)
duplicate symbol _kConnectionDown in:
    /Users/Library/Developer/Xcode/DerivedData/MyApplication-bchgbqjzuwjzbcbnhwyihhatsoyw/Build/Intermediates/MyApplication.build/Debug-iphonesimulator/MyApplication.build/Objects-normal/i386/Reachability.o
    /Users/Library/Developer/Xcode/DerivedData/MyApplication-bchgbqjzuwjzbcbnhwyihhatsoyw/Build/Products/Debug-iphonesimulator/libPOSNirvanaUtils.a(Reachability.o)
ld: 8 duplicate symbols for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I have project structure like

我有项目结构

  1. Application
  2. 应用程序
  3. Static library A
  4. 静态库
  5. Static library B
  6. 静态库B

Situation 1) Static library A depend on static library B. The project A require Reachability check. 2) Added static library A into Application project 3) When I compile,getting linker error

情境1)静态库A依赖于静态库b。项目A需要可达性检查。2)在应用程序项目中添加静态库A) 3)在编译时,会出现链接错误

Please help to resolve this issue.

请帮忙解决这个问题

5 个解决方案

#1


1  

If this solution is not working then check this..

如果这个解决方案不起作用,那么检查一下。

Another reason this error often happens is accidentally importing the .m file instead of the .h.

这个错误经常发生的另一个原因是不小心导入了.m文件而不是.h文件。

#2


0  

Steps:

步骤:

1.Check Build phases in Target settings.

1。检查目标设置中的构建阶段。

2.Check if any file exists twice or once.

2。检查任何文件是否存在两次或一次。

3.If file exist twice delete one. If not delete file in the bottom which is the latest one.

3所示。如果文件存在两次,删除一个。如果不删除文件在底部是最新的一个。

4.Build again.

4所示。再次构建。

#3


0  

You have Reachability class in libPOSNirvanaUtils.a & your Application and you are using libPOSNirvanaUtils.a in your application. So now your application has 2 reference of Reachability class.

在libPOSNirvanaUtils中有可达性类。你的应用程序和你正在使用libPOSNirvanaUtils。在您的应用程序。现在你的应用程序有两个可达性类的引用。

If you are building libPOSNirvanaUtils.a then you can solve this with 2 ways:

如果你正在构建libPOSNirvanaUtils。a那么你可以用两种方法来解决这个问题:

  1. Remove Reachability class membership from target libPOSNirvanaUtils.a
  2. 从目标libposnirvanautilis中删除可达性类成员
  3. Add Reachability class in Copy files, remove Reachability class reference from your Application and use same class reference from libPOSNirvanaUtils.
  4. 在复制文件中添加可达性类,从应用程序中删除可达性类引用,并使用libPOSNirvanaUtils的相同类引用。

#4


0  

I had the same problem while using prepareforsegue delegate. It turns out, I accidentally imported the .m file instead of the .h file. This will fix it. Look at your #import statements before you go crazy adding and deleting frameworks.

我在使用prepareforsegue委托时遇到了同样的问题。结果是,我不小心导入了.m文件而不是.h文件。这将解决它。在疯狂地添加和删除框架之前,请查看#import语句。

#5


0  

In my case I got this error because had the same named variables declared in several files in implementation part.

在我的例子中,我得到了这个错误,因为在实现部分的几个文件中声明了相同的命名变量。

@implementation A
int a;
...

@implementation B
int a;
...

gave me "duplicate symbol _a ..."

给我"重复符号_a…"

#1


1  

If this solution is not working then check this..

如果这个解决方案不起作用,那么检查一下。

Another reason this error often happens is accidentally importing the .m file instead of the .h.

这个错误经常发生的另一个原因是不小心导入了.m文件而不是.h文件。

#2


0  

Steps:

步骤:

1.Check Build phases in Target settings.

1。检查目标设置中的构建阶段。

2.Check if any file exists twice or once.

2。检查任何文件是否存在两次或一次。

3.If file exist twice delete one. If not delete file in the bottom which is the latest one.

3所示。如果文件存在两次,删除一个。如果不删除文件在底部是最新的一个。

4.Build again.

4所示。再次构建。

#3


0  

You have Reachability class in libPOSNirvanaUtils.a & your Application and you are using libPOSNirvanaUtils.a in your application. So now your application has 2 reference of Reachability class.

在libPOSNirvanaUtils中有可达性类。你的应用程序和你正在使用libPOSNirvanaUtils。在您的应用程序。现在你的应用程序有两个可达性类的引用。

If you are building libPOSNirvanaUtils.a then you can solve this with 2 ways:

如果你正在构建libPOSNirvanaUtils。a那么你可以用两种方法来解决这个问题:

  1. Remove Reachability class membership from target libPOSNirvanaUtils.a
  2. 从目标libposnirvanautilis中删除可达性类成员
  3. Add Reachability class in Copy files, remove Reachability class reference from your Application and use same class reference from libPOSNirvanaUtils.
  4. 在复制文件中添加可达性类,从应用程序中删除可达性类引用,并使用libPOSNirvanaUtils的相同类引用。

#4


0  

I had the same problem while using prepareforsegue delegate. It turns out, I accidentally imported the .m file instead of the .h file. This will fix it. Look at your #import statements before you go crazy adding and deleting frameworks.

我在使用prepareforsegue委托时遇到了同样的问题。结果是,我不小心导入了.m文件而不是.h文件。这将解决它。在疯狂地添加和删除框架之前,请查看#import语句。

#5


0  

In my case I got this error because had the same named variables declared in several files in implementation part.

在我的例子中,我得到了这个错误,因为在实现部分的几个文件中声明了相同的命名变量。

@implementation A
int a;
...

@implementation B
int a;
...

gave me "duplicate symbol _a ..."

给我"重复符号_a…"