问题
I'm attempting to call Card.IO from my Xamarin app. I get "Undefined symbols for architecture i386:" when I try to compile my app and it cites "std::terminate()" in the message. The app is intended for iPhone, I don't know where did the "i386" come from - all settings in project options that I can find are set to ARMv7, so is the LinkWith attribute in the binding.
Card.IO's guide states I need to add -lstdc++
to "other linker flags" in Xcode but I don't know where should I put this in Xamarin Studio's options
Question is: how do I make this binding work? Is there an error in the binding? Is there some project setting or somehow adding more framework references in my app?
I used Objective Sharpie to generate the code below
using System;
using System.Drawing;
using MonoTouch.ObjCRuntime;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
namespace CardIO
{
[BaseType (typeof (NSObject))]
public partial interface CardIOCreditCardInfo {
[Export ("cardNumber")]
string CardNumber { get; set; }
[Export ("redactedCardNumber")]
string RedactedCardNumber { get; }
[Export ("expiryMonth")]
uint ExpiryMonth { get; set; }
[Export ("expiryYear")]
uint ExpiryYear { get; set; }
[Export ("cvv")]
string Cvv { get; set; }
[Export ("zip")]
string Zip { get; set; }
[Export ("scanned")]
bool Scanned { get; set; }
[Export ("cardType")]
CardIOCreditCardType CardType { get; }
[Static, Export ("displayStringForCardType:usingLanguageOrLocale:")]
string DisplayStringForCardType (CardIOCreditCardType cardType, string languageOrLocale);
[Static, Export ("logoForCardType:")]
NSObject LogoForCardType (CardIOCreditCardType cardType);
}
[Model]
[BaseType (typeof (NSObject))]
public partial interface CardIOPaymentViewControllerDelegate {
[Export ("userDidCancelPaymentViewController:")]
void UserDidCancelPaymentViewController (CardIOPaymentViewController paymentViewController);
[Export ("userDidProvideCreditCardInfo:inPaymentViewController:")]
void UserDidProvideCreditCardInfo (CardIOCreditCardInfo info, CardIOPaymentViewController paymentViewController);
}
[BaseType (typeof (UINavigationController))]
public partial interface CardIOPaymentViewController {
[Export ("initWithPaymentDelegate:")]
IntPtr Constructor (CardIOPaymentViewControllerDelegate aDelegate);
[Export ("initWithPaymentDelegate:scanningEnabled:")]
IntPtr Constructor (CardIOPaymentViewControllerDelegate aDelegate, bool scanningEnabled);
[Export ("appToken")]
string AppToken { get; set; }
[Export ("languageOrLocale")]
string LanguageOrLocale { get; set; }
[Export ("keepStatusBarStyle")]
bool KeepStatusBarStyle { get; set; }
[Export ("navigationBarStyle")]
UIBarStyle NavigationBarStyle { get; set; }
[Export ("navigationBarTintColor")]
UIColor NavigationBarTintColor { get; set; }
[Export ("disableBlurWhenBackgrounding")]
bool DisableBlurWhenBackgrounding { get; set; }
[Export ("collectExpiry")]
bool CollectExpiry { get; set; }
[Export ("collectCVV")]
bool CollectCvv { get; set; }
[Export ("collectZip")]
bool CollectZip { get; set; }
[Export ("showsFirstUseAlert")]
bool ShowsFirstUseAlert { get; set; }
[Export ("useCardIOLogo")]
bool UseCardIolOgo { get; set; }
[Export ("disableManualEntryButtons")]
bool DisableManualEntryButtons { get; set; }
[Export ("paymentDelegate")]
CardIOPaymentViewControllerDelegate PaymentDelegate { get; set; }
[Export ("canReadCardWithCamera")]
bool CanReadCardWithCamera { get; }
[Export ("libraryVersion")]
string LibraryVersion { get; }
}
}
I also added the frameworks listed in Card.IO's site to the .linkswith file:
[assembly: LinkWith ("libCardIO.a", LinkTarget.ArmV7 | LinkTarget.ArmV7s | LinkTarget.Simulator, ForceLoad = true
, Frameworks="AVFoundation AudioToolbox CoreMedia CoreVideo MobileCoreServices OpenGLES QuartzCore Security UIKit")]
Then I added a project reference in my app to the newly created binding project but it doesn't compile. I get this error in Xamarin's output console:
Process exited with code 1, command:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc -Wl,-no_pie -arch i386 -gdwarf-2 -fobjc-legacy-dispatch -fobjc-abi-version=2 -miphoneos-version-min=6.1 -arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.1.sdk /Users/Sten/Dropbox/Code/Projects/Tabit/TabitOne_iPhone/TabitOne/obj/iPhoneSimulator/Debug/mtouch-cache/main.i386.cache.OHBLJlHbpZ74bpnhszg9JrCN8A8=.o -o /var/folders/bb/2tbfzn4n2dq6rsmtpv_jlmbr0000gq/T/tmp59582304.tmp/TabitOne -framework CFNetwork -framework AssetsLibrary -framework Accounts -framework CoreBluetooth -framework CoreTelephony -framework EventKit -framework EventKitUI -framework Foundation -framework CoreMotion -framework GameKit -framework GLKit -framework iAd -framework MapKit -framework MediaPlayer -framework MessageUI -framework NewsstandKit -framework OpenGLES -framework Social -framework StoreKit -framework Twitter -framework UIKit -framework PassKit -framework AddressBookUI -framework AudioToolbox -framework SystemConfiguration -framework AddressBook -framework AVFoundation -framework QuartzCore -framework CoreData -framework CoreGraphics -framework CoreImage -framework CoreLocation -framework CoreText -framework ImageIO -framework MobileCoreServices -framework Security -framework CoreMedia -framework CoreMIDI -framework CoreVideo -framework ExternalAccessory -framework AdSupport -framework QuickLook -lz -liconv -u _mono_pmip -u _monotouch_create_managed_ref -u _monotouch_release_managed_ref -u _monotouch_IntPtr_objc_msgSend_IntPtr -u _monotouch_IntPtr_objc_msgSendSuper_IntPtr -u _CloseZStream -u _CreateZStream -u _Flush -u _ReadZStream -u _WriteZStream -lmono-2.0 -lmonotouch-debug -L/Developer/MonoTouch/SDKs/MonoTouch.iphonesimulator.sdk/usr/lib -u _catch_exception_raise -force_load /var/folders/bb/2tbfzn4n2dq6rsmtpv_jlmbr0000gq/T/tmp59582304.tmp/libCardIO.a
**Undefined symbols for architecture i386:**
"**std::terminate()**", referenced from:
-[CardIOGPURenderer dealloc] in libCardIO.a(CardIOGPURenderer.o)
"___gxx_personality_v0", referenced from:
Dwarf Exception Unwind Info (__eh_frame) in libCardIO.a(CardIOAnalytics.o)
Dwarf Exception Unwind Info (__eh_frame) in libCardIO.a(CardIOGPURenderer.o)
Dwarf Exception Unwind Info (__eh_frame) in libCardIO.a(CardIOAnimation.o)
Dwarf Exception Unwind Info (__eh_frame) in libCardIO.a(CardIOAnalytics.o)
Dwarf Exception Unwind Info (__eh_frame) in libCardIO.a(CardIOGPURenderer.o)
Dwarf Exception Unwind Info (__eh_frame) in libCardIO.a(CardIOAnimation.o)
Dwarf Exception Unwind Info (__eh_frame) in libCardIO.a(CardIOAnalytics.o)
Dwarf Exception Unwind Info (__eh_frame) in libCardIO.a(CardIOGPURenderer.o)
Dwarf Exception Unwind Info (__eh_frame) in libCardIO.a(CardIOAnimation.o)
ld: symbol(s) not found for architecture i386
collect2: ld returned 1 exit status
error MT5202: Native linking failed. Please review the build log.
回答1:
Ok, thanks to the answer in another SO post I got this to work by editing my app's project options, page "iOS Build", field "Additional mtouch arguments" where I put the value:
-cxx -gcc_flags "-lstdc++"
来源:https://stackoverflow.com/questions/16779467/card-io-binding-project-fails-app-compilation