Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Dll import issue in native plugin

Discussion in 'iOS and tvOS' started by Inisle - Developer, Jun 22, 2015.

  1. Inisle - Developer

    Inisle - Developer

    Joined:
    Feb 9, 2015
    Posts:
    6
    Hi everybody.

    We are trying to implement out first native plugin for iOS.

    What we wanto do is use a third party library (is a static library .a) to implement some logic layer over it. We put third-party library in to Assets/Plugins/iOS.

    All compilation & build phases went fine but we're getting linkage into device. Static library are included into dependencies of the generated project.

    DllNotFoundException: Unable to load DLL 'libThirdParty': The specified module could not be found.

    We also try with ("ThirdParty", "libThirdParty", "libThirdParty.a")
    [DllImport ("ThirdParty")]
    private static extern void HelloWorldPluginFunction();

    [DllImport ("libThirdParty")]
    private static extern void HelloWorldPluginFunction();

    [DllImport ("libThirdParty.a")]
    private static extern void HelloWorldPluginFunction();

    What we are forgetting / doing bad?. Anyone was found same problems.

    Thanks in advanced,
     

    Attached Files:

  2. Alexey

    Alexey

    Unity Technologies

    Joined:
    May 10, 2010
    Posts:
    1,602
    on ios you should do
    [DllImport("__Internal")]
     
  3. Inisle - Developer

    Inisle - Developer

    Joined:
    Feb 9, 2015
    Posts:
    6
    Using [DllImport("__Internal")], XCode reports next link errors.

    Undefined symbols for architecture arm64:

    "_HelloWorldPluginFunction", referenced from:

    _OurFirstPluginProxy_FaceMePluginFunction_m1 in Bulk_Assembly-CSharp-firstpass_0.o

    (maybe you meant: _OurFirstPluginProxy_HelloWorldPluginFunction_m1_MethodInfo, _OurFirstPluginProxy_HelloWorldPluginFunction_m1 )

    ld: symbol(s) not found for architecture arm64

    clang: error: linker command failed with exit code 1 (use -v to see invocation)
     
  4. Alexey

    Alexey

    Unity Technologies

    Joined:
    May 10, 2010
    Posts:
    1,602
    remove "static" from your header
     
  5. Inisle - Developer

    Inisle - Developer

    Joined:
    Feb 9, 2015
    Posts:
    6
    Thank you very much Alexey.

    We are a bit step closer to the solution.

    We have run into new difficulties. Internally our plugin uses an external framework. Simply deploy generate project we got:

    "
    dyld: Library not loaded: @rpath/FaceMe.framework/FaceMe

    Referenced from: /private/var/mobile/Containers/Bundle/Application/98E85F0B-E7D9-4C66-A49E-996EDF311F47/ProductName.app/ProductName

    Reason: image not found
    "

    Even so after

    * Add framework reference.
    * Add framework to embedded binaries setting.
    * Add a extra copy build step to install frameworks in Frameworks
    * Set '@executable_path/Frameworks' to Runpath search Paths

    Same result! :-(.


    Is it possible to create a native plugin that use external framework?.

    Thank in advanced
     
  6. povilas

    povilas

    Unity Technologies

    Joined:
    Jan 28, 2014
    Posts:
    427
  7. Inisle - Developer

    Inisle - Developer

    Joined:
    Feb 9, 2015
    Posts:
    6
    OH!!!! It's alive!

    Very thx povilas.
     
  8. HeathC

    HeathC

    Joined:
    Oct 17, 2016
    Posts:
    110
    I understand this is an old thread, but this is the only place I've seen any hope for a week now as I'm getting the exact kind of error as op

    I'm getting this error in Xcode
    Code (CSharp):
    1. Undefined symbols for architecture arm64:
    2.   "__unityTapticIsSupport", referenced from:
    3.       _TapticManager_IsSupport_mADBE6C1751030925D79B930DDB17B1D746603C29 in Assembly-CSharp5.o
    4.       _TapticManager__unityTapticIsSupport_mD9FBB8237C589E9CA90CE31B718C8D8859237DCB in Assembly-CSharp5.o
    5.      (maybe you meant: _TapticManager__unityTapticIsSupport_mD9FBB8237C589E9CA90CE31B718C8D8859237DCB)
    6.   "__unityTapticImpact", referenced from:
    7.       _TapticManager_Impact_m756F7B9F2CEEEF90D0A9EA7EDABAE56E6EA18F2C in Assembly-CSharp5.o
    8.       _TapticManager__unityTapticImpact_m4F8AA189DEFAB5590E8A08680DB6FE07C6682FB3 in Assembly-CSharp5.o
    9.      (maybe you meant: _TapticManager__unityTapticImpact_m4F8AA189DEFAB5590E8A08680DB6FE07C6682FB3)
    10.   "__unityTapticSelection", referenced from:
    11.       _TapticManager_Selection_m52193285DA40B5A88C065CA88214F3FE524F8AA6 in Assembly-CSharp5.o
    12.       _TapticManager__unityTapticSelection_m06C11D6513340D0518D65E8C065777895D1D4CC1 in Assembly-CSharp5.o
    13.      (maybe you meant: _TapticManager__unityTapticSelection_m06C11D6513340D0518D65E8C065777895D1D4CC1)
    14.   "__unityTapticNotification", referenced from:
    15.       _TapticManager_Notification_mAC7242D4C817986B9B2943B730CA4166CFA23969 in Assembly-CSharp5.o
    16.       _TapticManager__unityTapticNotification_m3B907AA8EB1DB3F0EDE84D1130A56E04B9F37109 in Assembly-CSharp5.o
    17.      (maybe you meant: _TapticManager__unityTapticNotification_m3B907AA8EB1DB3F0EDE84D1130A56E04B9F37109)
    18. ld: symbol(s) not found for architecture arm64
    19. clang: error: linker command failed with exit code 1 (use -v to see invocation)
    I believe this is the code in question

    Code (CSharp):
    1. using System.Runtime.InteropServices;
    2.  
    3. namespace TapticPlugin
    4. {
    5.     public enum NotificationFeedback
    6.     {
    7.         Success,
    8.         Warning,
    9.         Error
    10.     }
    11.  
    12.     public enum ImpactFeedback
    13.     {
    14.         Light,
    15.         Medium,
    16.         Heavy
    17.     }
    18.  
    19.     public static class TapticManager
    20.     {
    21.  
    22.         public static void Notification(NotificationFeedback feedback)
    23.         {
    24.             _unityTapticNotification((int)feedback);
    25.         }
    26.  
    27.         public static void Impact(ImpactFeedback feedback)
    28.         {
    29.             _unityTapticImpact((int)feedback);
    30.         }
    31.  
    32.         public static void Selection()
    33.         {
    34.             _unityTapticSelection();
    35.         }
    36.  
    37.         public static bool IsSupport()
    38.         {
    39.             return _unityTapticIsSupport();
    40.         }
    41.  
    42.         #region DllImport
    43.  
    44. #if UNITY_IPHONE && !UNITY_EDITOR
    45.         [DllImport("__Internal")]
    46.         private static extern void _unityTapticNotification(int type);
    47.         [DllImport("__Internal")]
    48.         private static extern void _unityTapticSelection();
    49.         [DllImport("__Internal")]
    50.         private static extern void _unityTapticImpact(int style);
    51.         [DllImport("__Internal")]
    52.         private static extern bool _unityTapticIsSupport();
    53. #else
    54.         private static void _unityTapticNotification(int type) { }
    55.  
    56.         private static void _unityTapticSelection() { }
    57.  
    58.         private static void _unityTapticImpact(int style) { }
    59.  
    60.         private static bool _unityTapticIsSupport() { return false; }
    61. #endif
    62.  
    63.         #endregion // DllImport
    64.     }
    65.  
    66. }
    How would I get this to stop throwing that error?
     
  9. joshuacwilde

    joshuacwilde

    Joined:
    Feb 4, 2018
    Posts:
    692
    There was a recent(?) change in unity where you now need to make sure the files get linked to the framework, rather than the app in xcode.