0

Possibly related to Unmanaged C# calls to a static library by https://stackoverflow.com/users/456434/mazyod

I'm trying to build an iOS app using the HoloToolkit.Sharing library (https://github.com/Microsoft/MixedRealityToolkit/tree/master/Sharing) which is in turn based on several open source components including RakNet.

After building the library and its dependencies as static libraries for arm64, and manually changing the DLL references to __Internal, I am able to load the plugin in iOS but the app throws an exception:

EntryPointNotFoundException: SWIGRegisterExceptionCallbacks_SharingClient
HoloToolkit.Sharing.SharingClientPINVOKE+SWIGExceptionHelper..cctor () (at Assets/HoloToolkit/Sharing/Scripts/SDK/SharingClientPINVOKE.cs:150)

The wrapper looks like this:

        [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);

As far as I can tell, the necessary wrappers from swig are also included in the C++ project (found in 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;
}

Building with IL2CPP and .NET 2.0 Subset, using -unsafe flag in Unity 5.5.2f1 64-bit on Mac OS X 10.12, Xcode 9.0 beta 2, iOS 11 beta.

Is there something else I need to change to get the __Internal reference to work? Or, is there's something else needed for the wrapper to find the callback (I found this very old thread mentioning the need to build a "helper dll": http://swig.10945.n7.nabble.com/C-wrapper-tries-to-find-SWIGRegisterExceptionCallbacks-MyDLL-td6935.html)?

8
  • Ok, so I've traced the issue to the static library itself. It seems that the arm64 slice is missing the relevant symbols - at least I am unable to read them out using nm from the library file libSharingClient.a. I've tried looking at the contents with file, lipo and otool as well. They contain the correct architectures (armv7, arm64) but I'm unable to locate the relevant symbols. There are 200+ linking errors, all in the form of missing symbols:
    – anderslu
    Sep 8, 2017 at 11:16
  • Undefined symbols for architecture arm64: "_SWIGRegisterExceptionArgumentCallbacks_SharingClient", referenced from: _SWIGExceptionHelper_SWIGRegisterExceptionCallbacksArgument_SharingClient_m3189746330 in Bulk_Assembly-CSharp_1.o
    – anderslu
    Sep 8, 2017 at 11:17
  • And how do you solve these missing symbols?
    – ivan866
    Apr 8, 2019 at 15:45
  • 1
    We ended up adding the C++ source directly to our XCode project and build together with the Unity project. Worked great.
    – anderslu
    Apr 9, 2019 at 16:34
  • You mean you've incorporated the cpp code right inside the custom Unity sources and deployed it that way?
    – ivan866
    Apr 10, 2019 at 5:08

0

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.