Bug 17032 - Monotouch Binding/Linking Amazon GameCircle for iOS - error MT5212: Native linking failed, duplicate symbol: '_MD5'
Summary: Monotouch Binding/Linking Amazon GameCircle for iOS - error MT5212: Native li...
Status: RESOLVED INVALID
Alias: None
Product: iOS
Classification: Xamarin
Component: Tools ()
Version: 7.1.0.x
Hardware: PC Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2014-01-03 04:39 UTC by matteo.polito
Modified: 2014-01-06 14:45 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED INVALID

Description matteo.polito 2014-01-03 04:39:10 UTC
Hi guys, I've a problem on binding GameCircle library by Amazon. They offer the Unity plugin for they library, I want to use classes they made for Unity on Monotouch. I've extracted unity plugin and now I want to use it on Monotouch. I've created a project and hosted it on GitHub (https://github.com/mapo80/GameCircle.Monotouch).

There are two libraries: 
- AmazonInsightsSDK.a 
- GameCircle.a

I'm using this linkWith parameters: [assembly: LinkWith ("AmazonInsightsSDK.a", LinkTarget.ArmV7 | LinkTarget.ArmV7s | LinkTarget.Simulator, ForceLoad = true, IsCxx = true, LinkerFlags="-lsqlite3.0 -lstdc++", Frameworks = "AdSupport GameKit MessageUI CoreTelephony SystemConfiguration Security ExternalAccessory Foundation")]

[assembly: LinkWith ("GameCircle.a", LinkTarget.Simulator | LinkTarget.ArmV7 | LinkTarget.ArmV7s, ForceLoad = true, IsCxx = true, LinkerFlags="-lsqlite3.0 -lstdc++", Frameworks = "AdSupport GameKit MessageUI CoreTelephony SystemConfiguration Security ExternalAccessory Foundation")]

When I reference dll on my iOS projects I obtain these errors:

Compiling to native code /Developer/MonoTouch/usr/bin/mtouch -sdkroot "/Applications/Xcode.app/Contents/Developer" --cache "/Users/matteo/Desktop/Monotouch.AmazonGameCircleBinding/Monotouch.AmazonGameCircleTestApp/obj/iPhoneSimulator/Debug/mtouch-cache" --nomanifest --nosign -sim "/Users/matteo/Desktop/Monotouch.AmazonGameCircleBinding/Monotouch.AmazonGameCircleTestApp/bin/iPhoneSimulator/Debug/MonotouchAmazonGameCircleTestApp.app" -r "/Users/matteo/Desktop/Monotouch.AmazonGameCircleBinding/Monotouch.AmazonGameCircleBinding/bin/Debug/Monotouch.AmazonGameCircleBinding.dll" -r "/Developer/MonoTouch/usr/lib/mono/2.1/System.dll" -r "/Developer/MonoTouch/usr/lib/mono/2.1/System.Xml.dll" -r "/Developer/MonoTouch/usr/lib/mono/2.1/System.Core.dll" -r "/Developer/MonoTouch/usr/lib/mono/2.1/monotouch.dll" -debug -nolink -sdk "7.0" -targetver "7.0" --abi=i386 "/Users/matteo/Desktop/Monotouch.AmazonGameCircleBinding/Monotouch.AmazonGameCircleTestApp/bin/iPhoneSimulator/Debug/MonotouchAmazonGameCircleTestApp.exe" Xamarin.iOS 7.0.6 Business Edition using framework: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.0.sdk Process exited with code 1, command: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -lsqlite3.0 -lstdc++ -Wl,-pie -gdwarf-2 -arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.0.sdk -Qunused-arguments -fobjc-legacy-dispatch -fobjc-abi-version=2 -mios-simulator-version-min=7.0 /Users/matteo/Desktop/Monotouch.AmazonGameCircleBinding/Monotouch.AmazonGameCircleTestApp/obj/iPhoneSimulator/Debug/mtouch-cache/main.i386.o -force_load /Users/matteo/Desktop/Monotouch.AmazonGameCircleBinding/Monotouch.AmazonGameCircleTestApp/obj/iPhoneSimulator/Debug/mtouch-cache/AmazonInsightsSDK.a -force_load /Users/matteo/Desktop/Monotouch.AmazonGameCircleBinding/Monotouch.AmazonGameCircleTestApp/obj/iPhoneSimulator/Debug/mtouch-cache/GameCircle.a -o /Users/matteo/Desktop/Monotouch.AmazonGameCircleBinding/Monotouch.AmazonGameCircleTestApp/bin/iPhoneSimulator/Debug/MonotouchAmazonGameCircleTestApp.app/MonotouchAmazonGameCircleTestApp -framework CFNetwork -framework AVFoundation -framework Accelerate -framework AddressBook -framework AudioToolbox -framework QuartzCore -framework CoreBluetooth -framework CoreData -framework CoreGraphics -framework CoreImage -framework CoreLocation -framework CoreText -framework Foundation -framework GameKit -framework ImageIO -framework MobileCoreServices -framework Security -framework SystemConfiguration -framework CoreMedia -framework CoreMIDI -framework CoreVideo -framework StoreKit -framework AssetsLibrary -framework Accounts -framework CoreTelephony -framework EventKit -framework EventKitUI -framework CoreMotion -framework GLKit -framework iAd -framework MapKit -framework MediaPlayer -framework MessageUI -framework NewsstandKit -framework OpenGLES -framework Social -framework Twitter -framework UIKit -framework PassKit -framework SpriteKit -framework JavaScriptCore -framework MultipeerConnectivity -framework AddressBookUI -framework SafariServices -framework ExternalAccessory -framework AdSupport -framework QuickLook -lz -liconv -u _mono_pmip -u _xamarin_init_nsthread -u _xamarin_get_block_descriptor -u _monotouch_get_locale_country_code -u _monotouch_log -u _monotouch_start_wwan -u _monotouch_timezone_get_data -u _monotouch_timezone_get_names -u _monotouch_IntPtr_objc_msgSend_IntPtr -u _monotouch_IntPtr_objc_msgSendSuper_IntPtr -u _monotouch_release_managed_ref -u _monotouch_create_managed_ref -u _CloseZStream -u _CreateZStream -u _Flush -u _ReadZStream -u _WriteZStream /Developer/MonoTouch/SDKs/MonoTouch.iphonesimulator.sdk/usr/lib/libmonoboehm-2.0.a /Developer/MonoTouch/SDKs/MonoTouch.iphonesimulator.sdk/usr/lib/libmonotouch-debug.a duplicate symbol _MD5 in: /Users/matteo/Desktop/Monotouch.AmazonGameCircleBinding/Monotouch.AmazonGameCircleTestApp/obj/iPhoneSimulator/Debug/mtouch-cache/GameCircle.a(AGHelper.o) /Users/matteo/Desktop/Monotouch.AmazonGameCircleBinding/Monotouch.AmazonGameCircleTestApp/obj/iPhoneSimulator/Debug/mtouch-cache/GameCircle.a(md5_one.o) ld: 1 duplicate symbol for architecture i386 clang: error: linker command failed with exit code 1 (use -v to see invocation)

error MT5212: Native linking failed, duplicate symbol: '_MD5'. error MT5213: Duplicate symbol in: /Users/matteo/Desktop/Monotouch.AmazonGameCircleBinding/Monotouch.AmazonGameCircleTestApp/obj/iPhoneSimulator/Debug/mtouch-cache/GameCircle.a(AGHelper.o) (Location related to previous error) error MT5213: Duplicate symbol in: /Users/matteo/Desktop/Monotouch.AmazonGameCircleBinding/Monotouch.AmazonGameCircleTestApp/obj/iPhoneSimulator/Debug/mtouch-cache/GameCircle.a(md5_one.o) (Location related to previous error) error MT5309: Native linking error: 1 duplicate symbol for architecture i386 error MT5202: Native linking failed. Please review the build log.

Any help? What to do?

Thanks
Comment 1 Rolf Bjarne Kvinge [MSFT] 2014-01-06 08:08:10 UTC
This is a problem with the native library, it wasn't built correctly (there are
duplicated members in it).

You can most likely work around this by adding the following to all the LinkWith attributes
in the binding project:

    [assembly: LinkWith (..., SmartLink = true)]

and then add the following to the additional mtouch arguments in the iOS Build
options of the main project:

    --registrar:static

Alternatively you can ask the vendor of the native library to provide a
properly built library (this problem can be reproduced in an Xcode sample by
disabling dead strip for the linker and adding -load_all as an extra linker
flag).
Comment 2 matteo.polito 2014-01-06 14:45:23 UTC
Hi, thanks for tour answer. I've solved doing so:

-lipo thin for all platform ex. lipo -thin i386 -output GameCircle-x86.a GameCircle.a
-ar -r GameCircle-x86.a *.o
-remove md5_one.o
-libtool -static -o GameCircle-x86.a *.o
-Create new universal library lipo -create GameCircle-x86.a GameCircle-armv7.a GameCircle-armv7s.a -o GameCircle-MD5.a

Here the library:

https://github.com/mapo80/GameCircle.Monotouch