Unmanaged C# calls to a static library
可能与https://stackoverflow.com/users/456434/mazyod相关我正在尝试使用HoloToolkit.Sharing库(https://github.com/Microsoft/MixedRealityToolkit/tree/master/Sharing)构建iOS应用程序,而该库又基于包括RakNet在内的多个开源组件。
将库及其依赖项构建为arm64的静态库,并手动将DLL引用更改为__Internal之后,我可以在iOS中加载该插件,但应用程序会抛出异常:
EntryPointNotFoundException: SWIGRegisterExceptionCallbacks_SharingClient
HoloToolkit.Sharing.SharingClientPINVOKE+SWIGExceptionHelper..cctor () (at Assets/HoloToolkit/Sharing/Scripts/SDK/SharingClientPINVOKE.cs:150)
包装器看起来像这样:
[global::System.Runtime.InteropServices.DllImport ("__Internal", EntryPoint = "SWIGRegisterExceptionCallbacks_SharingClient")]
public static extern void SWIGRegisterExceptionCallbacks_SharingClient (
ExceptionDelegate applicationDelegate,
ExceptionDelegate arithmeticDelegate,
ExceptionDelegate divideByZeroDelegate,
ExceptionDelegate indexOutOfRangeDelegate,
ExceptionDelegate invalidCastDelegate,
ExceptionDelegate invalidOperationDelegate,
ExceptionDelegate ioDelegate,
ExceptionDelegate nullReferenceDelegate,
ExceptionDelegate outOfMemoryDelegate,
ExceptionDelegate overflowDelegate,
ExceptionDelegate systemExceptionDelegate);
据我所知,swig中必要的包装器也包含在C ++项目中(可在ClientWrapperAPI_CSharp.cpp中找到):
#ifdef __cplusplus
extern "C"
#endif
SWIGEXPORT void SWIGSTDCALL SWIGRegisterExceptionCallbacks_SharingClient(
SWIG_CSharpExceptionCallback_t applicationCallback,
SWIG_CSharpExceptionCallback_t arithmeticCallback,
SWIG_CSharpExceptionCallback_t divideByZeroCallback,
SWIG_CSharpExceptionCallback_t indexOutOfRangeCallback,
SWIG_CSharpExceptionCallback_t invalidCastCallback,
SWIG_CSharpExceptionCallback_t invalidOperationCallback,
SWIG_CSharpExceptionCallback_t ioCallback,
SWIG_CSharpExceptionCallback_t nullReferenceCallback,
SWIG_CSharpExceptionCallback_t outOfMemoryCallback,
SWIG_CSharpExceptionCallback_t overflowCallback,
SWIG_CSharpExceptionCallback_t systemCallback) {
SWIG_csharp_exceptions[SWIG_CSharpApplicationException].callback = applicationCallback;
SWIG_csharp_exceptions[SWIG_CSharpArithmeticException].callback = arithmeticCallback;
SWIG_csharp_exceptions[SWIG_CSharpDivideByZeroException].callback = divideByZeroCallback;
SWIG_csharp_exceptions[SWIG_CSharpIndexOutOfRangeException].callback = indexOutOfRangeCallback;
SWIG_csharp_exceptions[SWIG_CSharpInvalidCastException].callback = invalidCastCallback;
SWIG_csharp_exceptions[SWIG_CSharpInvalidOperationException].callback = invalidOperationCallback;
SWIG_csharp_exceptions[SWIG_CSharpIOException].callback = ioCallback;
SWIG_csharp_exceptions[SWIG_CSharpNullReferenceException].callback = nullReferenceCallback;
SWIG_csharp_exceptions[SWIG_CSharpOutOfMemoryException].callback = outOfMemoryCallback;
SWIG_csharp_exceptions[SWIG_CSharpOverflowException].callback = overflowCallback;
SWIG_csharp_exceptions[SWIG_CSharpSystemException].callback = systemCallback;
}
使用IL2CPP和.NET 2.0 Subset构建,在Mac OS X 10.12,Xcode 9.0 beta 2,iOS 11 beta上使用64位Unity 5.5.2f1中的-unsafe标志。
我需要更改其他内容以使__Internal引用起作用吗?或者,包装器找到回调是否需要其它东西(我发现这个非常老的线程提到需要构建一个" helper dll":http://swig.10945.n7.nabble.com/C-wrapper-tries-to-find-SWIGRegisterExceptionCallbacks-MyDLL-td6935.html)?