V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
iOS 开发实用技术导航
NSHipster 中文版
http://nshipster.cn/
cocos2d 开源 2D 游戏引擎
http://www.cocos2d-iphone.org/
CocoaPods
http://cocoapods.org/
Google Analytics for Mobile 统计解决方案
http://code.google.com/mobile/analytics/
WWDC
https://developer.apple.com/wwdc/
Design Guides and Resources
https://developer.apple.com/design/
Transcripts of WWDC sessions
http://asciiwwdc.com
Cocoa with Love
http://cocoawithlove.com/
Cocoa Dev Central
http://cocoadevcentral.com/
NSHipster
http://nshipster.com/
Style Guides
Google Objective-C Style Guide
NYTimes Objective-C Style Guide
Useful Tools and Services
Charles Web Debugging Proxy
Smore
banxi1988
V2EX  ›  iDev

请教库冲突的导致的 duplicate symbol 链接错误

  •  
  •   banxi1988 ·
    banxi1988 · 2014-05-23 11:41:37 +08:00 · 10113 次点击
    这是一个创建于 3634 天前的主题,其中的信息可能已经有所发展或是发生改变。
    怀疑是使用的SDK和本身项目使用同一个库造成冲突.
    错误消息:
    duplicate symbol _DegreesToRadians in:
    /Volumes/Store/NonPodVendor/ShareSDK/Extend/QQConnectSDK/TencentOpenAPI.framework/TencentOpenAPI(SetHeadImageViewController.o)
    Library/Developer/Xcode/DerivedData/Products/Debug-iphonesimulator/libPods.a(JCNotificationBannerPresenterIOSStyle.o)
    duplicate symbol _RadiansToDegrees in:
    /Volumes/Store/NonPodVendor/ShareSDK/Extend/QQConnectSDK/TencentOpenAPI.framework/TencentOpenAPI(SetHeadImageViewController.o)
    Library/Developer/Xcode/DerivedDataBuild/Products/Debug-iphonesimulator/libPods.a(JCNotificationBannerPresenterIOSStyle.o)
    ld: 2 duplicate symbols for architecture i386
    clang: error: linker command failed with exit code 1 (use -v to see invocation)

    从上面的错误信息上看是不是ShareSDK中带的;Tencent的Framework中
    与项目引用了同一个开源项目JSNotificationBannerPresenter 造成了冲突,
    如果是的话,要怎么改才比较好呢?如果不是?是什么问题?
    1 条回复    2014-05-23 11:59:41 +08:00
    banxi1988
        1
    banxi1988  
    OP
       2014-05-23 11:59:41 +08:00
    自己解决了,就贴下解决办法方便后来人吧.
    查看了JCNotificationBannerPresenterIOSStyle源代码,
    发现有冲突的是以下可能是由以下两个函数名,可能编译后编译器将名字加了_前缀.

    CGFloat DegreesToRadians(CGFloat degrees) { return degrees * M_PI / 180.0; };
    CGFloat RadiansToDegrees(CGFloat radians) { return radians * 180.0 / M_PI; };
    可能是作为两个简单的函数,跟其他的函数冲突了吧.
    我的做法时,不在使用cocoapods管理此库,而是下载下来做为项目的一部分,
    然后修改源代码:
    将上面的函数名更改一下:
    CGFloat MyDegreesToRadians(CGFloat degrees) { return degrees * M_PI / 180.0; };
    CGFloat MyRadiansToDegrees(CGFloat radians) { return radians * 180.0 / M_PI; };

    然后编译就通过了!~
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1160 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 17:54 · PVG 01:54 · LAX 10:54 · JFK 13:54
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.