将本机iOS库与xamarin绑定

时间:2013-12-22 11:52:46

标签: ios xamarin

我可以为.a库创建一个合适的dll

我的LinkWith文件

    [assembly: LinkWith ("libSwiperAPI.a", IsCxx = true, 
    LinkTarget = LinkTarget.Simulator | LinkTarget.ArmV7 | LinkTarget.ArmV7s, 
    ForceLoad = true, Frameworks = "CoreAudio AudioToolbox AVFoundation MediaPlayer", 
    LinkerFlags = "-ObjC -lc++" )]

在此尝试使用链接标志-lstdc ++ -lz但也没有用。

我甚至尝试在Addition mtouch Argjuments和-gcc_flags中添加-cxx。

当我尝试在我的演示项目中使用dll文件时。我收到错误

Compiling to native code
/Developer/MonoTouch/usr/bin/mtouch -sdkroot "/Applications/Xcode.app/Contents/Developer" --cache "/Users/sathish/Projects/Xamarin/RoamPayAPITest/RoamPayAPITest/obj/iPhone/Debug/mtouch-cache" --nomanifest --nosign -dev "/Users/sathish/Projects/Xamarin/RoamPayAPITest/RoamPayAPITest/bin/iPhone/Debug/RoamPayAPITest.app" -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" -r "/Users/sathish/Projects/Xamarin/RoamPayAPITest/References/SwipeAPIBinding.dll" -debug -sdk "7.0" -targetver "7.0" --abi=armv7 "-cxx" "/Users/sathish/Projects/Xamarin/RoamPayAPITest/RoamPayAPITest/bin/iPhone/Debug/RoamPayAPITest.exe"
Xamarin.iOS 7.0.4 Business Edition using framework: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk
warning MT3005: The dependency 'System.Xml, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' of the assembly 'monotouch, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065' was not found. Please review the project's references.
warning MT3005: The dependency 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' of the assembly 'SwipeAPIBinding, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' was not found. Please review the project's references.
warning MT3005: The dependency 'System, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' of the assembly 'SwipeAPIBinding, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' was not found. Please review the project's references.
warning MT3006: Could not compute a complete dependency map for the project. This will result in slower build times because Xamarin.iOS can't properly detect what needs to be rebuilt (and what does not need to be rebuilt). Please review previous warnings for more details.
Process exited with code 1, command:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++  -lz -lc++ -Wl,-pie  -miphoneos-version-min=7.0 -arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk  /Users/sathish/Projects/Xamarin/RoamPayAPITest/RoamPayAPITest/obj/iPhone/Debug/mtouch-cache/RoamPayAPITest.exe.armv7.o /Users/sathish/Projects/Xamarin/RoamPayAPITest/RoamPayAPITest/obj/iPhone/Debug/mtouch-cache/monotouch.dll.armv7.o /Users/sathish/Projects/Xamarin/RoamPayAPITest/RoamPayAPITest/obj/iPhone/Debug/mtouch-cache/mscorlib.dll.armv7.o /Users/sathish/Projects/Xamarin/RoamPayAPITest/RoamPayAPITest/obj/iPhone/Debug/mtouch-cache/SwipeAPIBinding.dll.armv7.o /Users/sathish/Projects/Xamarin/RoamPayAPITest/RoamPayAPITest/obj/iPhone/Debug/mtouch-cache/registrar.armv7.o /Users/sathish/Projects/Xamarin/RoamPayAPITest/RoamPayAPITest/obj/iPhone/Debug/mtouch-cache/main.armv7.o -force_load /Users/sathish/Projects/Xamarin/RoamPayAPITest/RoamPayAPITest/obj/iPhone/Debug/mtouch-cache/libSwiperAPI.a -o /Users/sathish/Projects/Xamarin/RoamPayAPITest/RoamPayAPITest/bin/iPhone/Debug/RoamPayAPITest.app/RoamPayAPITest -framework CFNetwork -framework Foundation -framework CoreGraphics -framework UIKit -framework CoreAudio -framework AudioToolbox -framework AVFoundation -framework MediaPlayer -lz -liconv -u _mono_pmip -u _monotouch_release_managed_ref -u _monotouch_create_managed_ref -u _monotouch_IntPtr_objc_msgSend_IntPtr -u _monotouch_IntPtr_objc_msgSendSuper_IntPtr -u _monotouch_log /Developer/MonoTouch/SDKs/MonoTouch.iphoneos.sdk/usr/lib/libmonoboehm-2.0.a /Developer/MonoTouch/SDKs/MonoTouch.iphoneos.sdk/usr/lib/libmonotouch-debug.a
Undefined symbols for architecture armv7:
  "std::ios_base::Init::Init()", referenced from:
      __GLOBAL__I_a in libSwiperAPI.a(DownSample.o)
      __GLOBAL__I_a in libSwiperAPI.a(FskController.o)
      __GLOBAL__I_a in libSwiperAPI.a(WavBuffer.o)
      __GLOBAL__I_a in libSwiperAPI.a(AE_ManchesterRealTimeDecoder.o)
      __GLOBAL__I_a in libSwiperAPI.a(AE_ManchesterState.o)
  "std::ios_base::Init::~Init()", referenced from:
      __GLOBAL__I_a in libSwiperAPI.a(DownSample.o)
      __GLOBAL__I_a in libSwiperAPI.a(FskController.o)
      __GLOBAL__I_a in libSwiperAPI.a(WavBuffer.o)
      __GLOBAL__I_a in libSwiperAPI.a(AE_ManchesterRealTimeDecoder.o)
      __GLOBAL__I_a in libSwiperAPI.a(AE_ManchesterState.o)
      __GLOBAL__I_a in libSwiperAPI.a(DownSample.o)
      __GLOBAL__I_a in libSwiperAPI.a(FskController.o)
      __GLOBAL__I_a in libSwiperAPI.a(WavBuffer.o)
      __GLOBAL__I_a in libSwiperAPI.a(AE_ManchesterRealTimeDecoder.o)
      __GLOBAL__I_a in libSwiperAPI.a(AE_ManchesterState.o)
      __GLOBAL__I_a in libSwiperAPI.a(DownSample.o)
      __GLOBAL__I_a in libSwiperAPI.a(FskController.o)
      __GLOBAL__I_a in libSwiperAPI.a(WavBuffer.o)
      __GLOBAL__I_a in libSwiperAPI.a(AE_ManchesterRealTimeDecoder.o)
      __GLOBAL__I_a in libSwiperAPI.a(AE_ManchesterState.o)
      __GLOBAL__I_a in libSwiperAPI.a(DownSample.o)
      __GLOBAL__I_a in libSwiperAPI.a(FskController.o)
      __GLOBAL__I_a in libSwiperAPI.a(WavBuffer.o)
      __GLOBAL__I_a in libSwiperAPI.a(AE_ManchesterRealTimeDecoder.o)
      __GLOBAL__I_a in libSwiperAPI.a(AE_ManchesterState.o)
      __GLOBAL__I_a in libSwiperAPI.a(DownSample.o)
      __GLOBAL__I_a in libSwiperAPI.a(FskController.o)
      __GLOBAL__I_a in libSwiperAPI.a(WavBuffer.o)
      __GLOBAL__I_a in libSwiperAPI.a(AE_ManchesterRealTimeDecoder.o)
      __GLOBAL__I_a in libSwiperAPI.a(AE_ManchesterState.o)
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
    error MT5210: Native linking failed, undefined symbol: std::ios_base::Init::Init().    
    Please verify that all the necessary frameworks have been referenced and native 
    libraries are properly linked in.

    error MT5210: Native linking failed, undefined symbol: std::ios_base::Init::~Init(). 
    Please verify that all the necessary frameworks have been referenced and native 
    libraries are properly linked in.

    error MT5202: Native linking failed. Please review the build log.

有人可以帮我解决这个问题。

1 个答案:

答案 0 :(得分:1)

终于找到了错误!!

    [assembly: LinkWith (..., LinkerFlags = "-lstdc++ -lz" )]

在iOS Binding Projet中

选项>构建>编译器>加法参数

    -cxx -gcc_flags "-stdlib=libstdc++ -L${ProjectDir} -lMylibrary -force_load ${ProjectDir}/libMylibrary.a”

在我的演示应用程序中

选项> iOS Buidl> Addtional mtouch Arguments

    --gcc_flags="-stdlib=libstdc++"

通过在所有地方提供适当的标志,它解决了我的问题。