同一个库的重复符号 XCode 重复库?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3334376/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Duplicate Symbol XCode duplicate library for same library?
提问by Vaseltior
Do you have any idea? Why XCode compilation give this result?
你有什么主意吗?为什么 XCode 编译会给出这个结果?
ld: duplicate symbol _kJSONDeserializerErrorDomain in
/Users/Shared/_BUILDS_/Debug-iphoneos/libLACDLibrary.a(CJSONDeserializer.o)
and /Users/Shared/_BUILDS_/Debug-iphoneos/libLACDLibrary.a(CJSONDeserializer.o)
采纳答案by Ariejan
Hey, you probably have a duplicate reference in XCode to CJSONDeserializer, so it's compiled and linked twice.
嘿,您可能在 XCode 中有一个对 CJSONDeserializer 的重复引用,因此它被编译和链接了两次。
回答by grinchdee
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.
我有完全一样的问题。它只抱怨 arm6 构建(不是 arm7 构建)。我找到了一个解决方法:在 Build<-Get Info<-Target 下的其他链接器标志中删除“-all_load”。我不确定这是否是正确的解决方法。我希望有人可以进一步解释并提供正确的解决方法,如果不是的话。
回答by Isaac Sutherland
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 oneof the projects actually links the library.
项目依赖项与将库链接在一起略有不同。多个项目依赖同一个共享库项目X是可以的;但是,请确保只有一个项目实际链接了库。
回答by Gavin Miller
I hit this issue with code like the following in a file called Common.h
:
我在一个名为的文件中使用如下代码解决了这个问题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) {
// ...
}