Duplicate symbol after migrating to 3.2RC0

Hey There,

I’m facing an issue where XCode’s linker finds a duplicate symbol when compiling to iOS.

Linker output below:

duplicate symbol __ZN7cocos2d10Controller15s_allControllerE in:
/Users/anderson/Library/Developer/Xcode/DerivedData/cupcakechef-cwqasmdnejxcksgintanrezujimo/Build/Products/Debug-iphonesimulator/libcocos2dx iOS.a(CCController-iOS.o)
/Users/anderson/Library/Developer/Xcode/DerivedData/cupcakechef-cwqasmdnejxcksgintanrezujimo/Build/Products/Debug-iphonesimulator/libcocos2dx iOS.a(CCController.o)

ld: 1 duplicate symbol for architecture i386

clang: error: linker command failed with exit code 1 (use -v to see invocation)

So far as I understand it, I’m trying to link CCController as well as CCController-iOS on the same project, and it seems to me they have definitions for the exact same classes/methods (which kinda makes sense, as one of them is the interface and the other is the actual implementation)… so how is it that they would conflict?

I’m totally lost on this one… any tips?

[EDIT]

After further research I found out that using -ObjC on other linker flags (required by the AdMob SDK) will lead to that error on Simulator builds. Runs fine on the device though.

I’m fine with AdMob only working on the device, but that would be nice if I was able to test it on the simulator as well… so if anyone can help, that would be much appreciated!

Thanks much!

  • Fabiano

I have the same problem here, unfortunately I need the simulator because I do not have an iOS device …

Any help?

When I remove the GameController.framework from Build Phases / Link Binary With Libraries
this error appears:

Undefined symbols for architecture i386:
  "_GCControllerDidConnectNotification", referenced from:
      -[GCControllerConnectionEventHandler observerConnection:disconnection:] in libcocos2dx iOS.a(CCController-iOS.o)
  "_GCControllerDidDisconnectNotification", referenced from:
      -[GCControllerConnectionEventHandler observerConnection:disconnection:] in libcocos2dx iOS.a(CCController-iOS.o)
  "_OBJC_CLASS_$_GCController", referenced from:
      objc-class-ref in libcocos2dx iOS.a(CCController-iOS.o)
     (maybe you meant: _OBJC_CLASS_$_GCControllerConnectionEventHandler)
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

When I add the GameController.framework in Build Phases / Link Binary With Libraries
this error appears:

duplicate symbol __ZN7cocos2d10Controller15s_allControllerE in:
    /Users/Jonathan/Library/Developer/Xcode/DerivedData/SpeedyJump-bdkxxynxsbevtddejoudhajmhvby/Build/Products/Debug-iphonesimulator/libcocos2dx iOS.a(CCController-iOS.o)
    /Users/Jonathan/Library/Developer/Xcode/DerivedData/SpeedyJump-bdkxxynxsbevtddejoudhajmhvby/Build/Products/Debug-iphonesimulator/libcocos2dx iOS.a(CCController.o)
ld: 1 duplicate symbol for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Let me have someone look at this.

It is fixed in this PR: https://github.com/cocos2d/cocos2d-x/pull/7338.
And it is merged in v3.2.
Will you download v3.2 and have a try?
Thanks.

Or you can merge the patch as the PR did.

Sorry about that.

Thank you, I can now view the Admob.

But other errors appeared only in console, I have no idea what it could be, but the app works normally:

2014-07-19 10:51:00.027 SpeedyJump iOS[24134:a0b] Error loading /System/Library/Extensions/IOHIDFamily.kext/Contents/PlugIns/IOHIDLib.plugin/Contents/MacOS/IOHIDLib:  dlopen(/System/Library/Extensions/IOHIDFamily.kext/Contents/PlugIns/IOHIDLib.plugin/Contents/MacOS/IOHIDLib, 262): Symbol not found: __dealloc
  Referenced from: /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
  Expected in: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.0.sdk/usr/lib/libobjc.A.dylib
 in /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
2014-07-19 10:51:00.028 SpeedyJump iOS[24134:a0b] Cannot find function pointer IOHIDLibFactory for factory 13AA9C44-6F1B-11D4-907C-0005028F18D5 in CFBundle/CFPlugIn 0xc923b00 </System/Library/Extensions/IOHIDFamily.kext/Contents/PlugIns/IOHIDLib.plugin> (bundle, not loaded)
2014-07-19 10:51:00.059 SpeedyJump iOS[24134:a0b] Error loading /System/Library/Extensions/IOHIDFamily.kext/Contents/PlugIns/IOHIDLib.plugin/Contents/MacOS/IOHIDLib:  dlopen(/System/Library/Extensions/IOHIDFamily.kext/Contents/PlugIns/IOHIDLib.plugin/Contents/MacOS/IOHIDLib, 262): Symbol not found: __dealloc
  Referenced from: /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
  Expected in: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.0.sdk/usr/lib/libobjc.A.dylib
 in /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
2014-07-19 10:51:00.060 SpeedyJump iOS[24134:a0b] Cannot find function pointer IOHIDLibFactory for factory 13AA9C44-6F1B-11D4-907C-0005028F18D5 in CFBundle/CFPlugIn 0xc923b00 </System/Library/Extensions/IOHIDFamily.kext/Contents/PlugIns/IOHIDLib.plugin> (bundle, not loaded)
2014-07-19 10:51:00.092 SpeedyJump iOS[24134:a0b] Error loading /System/Library/Extensions/IOHIDFamily.kext/Contents/PlugIns/IOHIDLib.plugin/Contents/MacOS/IOHIDLib:  dlopen(/System/Library/Extensions/IOHIDFamily.kext/Contents/PlugIns/IOHIDLib.plugin/Contents/MacOS/IOHIDLib, 262): Symbol not found: __dealloc
  Referenced from: /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
  Expected in: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.0.sdk/usr/lib/libobjc.A.dylib
 in /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
2014-07-19 10:51:00.092 SpeedyJump iOS[24134:a0b] Cannot find function pointer IOHIDLibFactory for factory 13AA9C44-6F1B-11D4-907C-0005028F18D5 in CFBundle/CFPlugIn 0xc923b00 </System/Library/Extensions/IOHIDFamily.kext/Contents/PlugIns/IOHIDLib.plugin> (bundle, not loaded)
2014-07-19 10:51:00.123 SpeedyJump iOS[24134:a0b] Error loading /System/Library/Extensions/IOHIDFamily.kext/Contents/PlugIns/IOHIDLib.plugin/Contents/MacOS/IOHIDLib:  dlopen(/System/Library/Extensions/IOHIDFamily.kext/Contents/PlugIns/IOHIDLib.plugin/Contents/MacOS/IOHIDLib, 262): Symbol not found: __dealloc
  Referenced from: /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
  Expected in: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.0.sdk/usr/lib/libobjc.A.dylib
 in /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
2014-07-19 10:51:00.124 SpeedyJump iOS[24134:a0b] Cannot find function pointer IOHIDLibFactory for factory 13AA9C44-6F1B-11D4-907C-0005028F18D5 in CFBundle/CFPlugIn 0xc923b00 </System/Library/Extensions/IOHIDFamily.kext/Contents/PlugIns/IOHIDLib.plugin> (bundle, not loaded)

It seems the error exist in admob library you used.
I am sorry, i don’t know what’s the error.

Great! Thanks you so much, Zhang!

Hi, Zhangxm:
I’m using cocos2dx v3.2. But the problem still exists in my project. Why? any other reason? Can you give me some help?

What is the error? The same as above? Are you using AdMob?

The error is exactly the same as above (I mean the duplicate symbol error).

I’m usng AdMob. The applicaiton can run on a Iphone5 real device. But When I try to use the simulator, the error appears.

How to reproduce it?

The project is created in cocos2dx v3.2. I just add Admob code in Appcontroller.h and AppController.mm. When I was trying to test the application by simulator (iPhone Retina 4-inch), the problem appear. But When I test with a real iPhone5s, there is no problem. What is your solution from v3.2RC to v3.2? Can you send me the fix? Thanks.

The pull request is https://github.com/cocos2d/cocos2d-x/pull/7338. But i am not sure if this pull request will resolve your problem.

Sorry, it’s my mistake. I created the project in cocos2dx 3.2 RC0. Now I copied the cocos2d folder of 3.2 version to my project folder. the problem is solved. Thank you.

i have a solution
add MediaPlayer.framework and GameController in link binaries.
it has solved my problem. may be it will work for you

1 Like

Error loading /System/Library/Extensions/IOHIDFamily.kext/ …
I get the same errors as this. That shows up in the simulator, not on the device. Did you end up figuring anything out ?

Hello, I am reviving this topic because when a similar problem when I tried to integrate Google Play Game Services SDK, see the error:

duplicate symbol _OPENSSL_cleanse in:
    /Volumes/01-Projetos/Cocos2d-x3.2rc0/00-Libs/Google Play/gpg.framework/gpg(libgpg.a-i386-master.o)
    /Users/Jonathan/Library/Developer/Xcode/DerivedData/Ghost_Run-cijyahoyskjltzbmaarynylpkymr/Build/Products/Debug-iphonesimulator/libcocos2dx iOS.a(x86cpuid.o)
ld: 1 duplicate symbol for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Anyone have any idea what could be the problem?