Duplicate Symbol XCode duplicate library for same library?

我们两清 提交于 2019-12-21 17:22:41

问题


Do you have any idea? Why XCode compilation give this result?

ld: duplicate symbol _kJSONDeserializerErrorDomain in 
  /Users/Shared/_BUILDS_/Debug-iphoneos/libLACDLibrary.a(CJSONDeserializer.o) 
  and /Users/Shared/_BUILDS_/Debug-iphoneos/libLACDLibrary.a(CJSONDeserializer.o)

回答1:


Hey, you probably have a duplicate reference in XCode to CJSONDeserializer, so it's compiled and linked twice.




回答2:


I have exactly the same problem. And it only complains for arm6 build (not arm7 build). I found a workaround: remove "-all_load" in Other linker flag under Build<-Get Info<-Target. I am not sure whether it is a correct workaround. I hope somebody can explain further and provide the correct workaround if this one is not.




回答3:


This error occurs if you link the same library into your project multiple times.

Project dependencies are subtly different from linking the libraries together. It is okay to have several projects depend on the same shared library project X; however, make sure that only one of the projects actually links the library.




回答4:


I hit this issue with code like the following in a file called Common.h:

void dumpViews(UIView* view, NSString *text, NSString *indent) {
  // ...
}

By adding static in front of the method definition it cleared the problem up for me:

static void dumpViews(UIView* view, NSString *text, NSString *indent) {
  // ...
}


来源:https://stackoverflow.com/questions/3334376/duplicate-symbol-xcode-duplicate-library-for-same-library

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!