duplicate symbol Linker Errors on iOS

TapOnFire
TapOnFire
edited May 2013 in Native
I'm trying to copy the demo project settings into my own project, since I can't find any documentation on how to set it up. It seems to go OK, all the header files are found etc, until the final linker stage. I'm adding to Other Linker Flags:
-lstdc++
-force_load
-... ...libCommon-objc... ....a
-ICommon-objc...
-IPhoton-obj...

When I add Photon-objc, I get lots of errors about duplicate symbols as it appears that they are defined in both Common-objc and Photon-objc, what can I do about this?

Comments

  • Your other linker flags look correct (I assume that these "..." are just there to shorten things up).
    Maybe its another setting. Would you mind posting the exact error log?
  • I'm getting lots of messages like this:
    duplicate symbol __ZN9ExitGames6Common10ANSIStringC1Ev in:
        /Users/brendon/Documents/SDKs/Photon-iOS_v3-2-1-1_Cloud_SDK/Photon-objc/lib/libPhoton-objc_Debug_iphoneos.a(ANSIString.o)
        /Users/brendon/Documents/SDKs/Photon-iOS_v3-2-1-1_Cloud_SDK/Common-objc/lib/libCommon-objc_Debug_iphoneos.a(ANSIString.o)
    

    I'm also a bit suspicious that I've included too much because I'm also getting a few of these (which reference both debug and release):
    duplicate symbol _OBJC_IVAR_$_EGLoadBalancingClient.mMasterserver in:
        /Users/brendon/Documents/SDKs/Photon-iOS_v3-2-1-1_Cloud_SDK/LoadBalancing-objc/lib/libLoadBalancing-objc_Debug_iphoneos.a(EGLoadBalancingClient.o)
        /Users/brendon/Documents/SDKs/Photon-iOS_v3-2-1-1_Cloud_SDK/LoadBalancing-objc/lib/libLoadBalancing-objc_release_iphoneos.a(EGLoadBalancingClient.o)
    

    My full Other Linker Flags (for the debug config) are:
    -all_load
    -weak_framework
    CoreMotion
    -weak-lSystem
    -lstdc++
    -force_load
    /Users/brendon/Documents/SDKs/Photon-iOS_v3-2-1-1_Cloud_SDK/Photon-objc/lib/libPhoton-objc_$(CONFIGURATION)_$(PLATFORM_NAME).a
    -lCommon-objc_$(CONFIGURATION)_$(PLATFORM_NAME)
    -lPhoton-objc_$(CONFIGURATION)_$(PLATFORM_NAME)
    -lLoadBalancing-objc_$(CONFIGURATION)_$(PLATFORM_NAME)
  • TapOnFire wrote:
    -all_load
    Ah, here we have the problem.
    Please don't use all_load or you will get those duplicate symbol errors.
    In general using all_load isn't a good idea. Some libs in that case will complain about duplicate symbol errors, others will just blew up your app size with unneeded stuff. all_load works like if you would use force_load on every single lib that you link in. Instead its by far preferable to only use force_load on the libs that actually need it, to avoid issues with other libs.
    So you should identify, which libs actually get into trouble, when you throw out all_load and add a force_load on each of these and only these libs, just like you are already doing for Common-objc.

    PS:
    Here is another thread about this topic:
    viewtopic.php?p=3946#p3946