Search Unity

Fallback handler could not load Library, Unity 4.2, OSX 10.8.4 standalone

Discussion in 'Editor & General Support' started by Smooth-P, Jul 23, 2013.

  1. Smooth-P

    Smooth-P

    Joined:
    Sep 15, 2012
    Posts:
    214
    I'm getting three dozen + "Fallback handler could not load library" messages on startup when running my standalone player project built in Unity 4.2 on OSX 10.8.4.

    The game seems to run fine, but I'm wondering what these messages mean and how to get rid of them...
     
  2. Smooth-P

    Smooth-P

    Joined:
    Sep 15, 2012
    Posts:
    214
    Nobody else is getting this?
     
  3. ikriz

    ikriz

    Joined:
    Dec 3, 2009
    Posts:
    98
    Having the same issue on windows loading my own native plugin.

    Plugin is located in Plugins directory and unity is looking for a fallback in
    Fallback handler could not load library C:/Program Files (x86)/Unity 4.2/Editor/Data/Mono/lib/.<full path to dll>

    It could be because i've added ffmpeg or a multiple of other things? Currently i dont get why this error is here.

    Code (csharp):
    1.  
    2. Fallback handler could not load library C:/Program Files (x86)/Unity 4.2/Editor/Data/Mono/lib/.\D:/Unity/.../Assets/Plugins/myplug.dll
    3. Fallback handler could not load library C:/Program Files (x86)/Unity 4.2/Editor/Data/Mono/lib/.\D:/Unity/.../Assets/Plugins/myplug
    4. Fallback handler could not load library C:/Program Files (x86)/Unity 4.2/Editor/Data/Mono/lib/libD:/Unity/.../Assets/Plugins/myplug.dll
    5. ...
    6. DllNotFoundException: D:/Unity/.../Assets/Plugins/myplug.dll
    7.   at (wrapper managed-to-native) MyPlug:InitializePlugin (MyPlug/StringParamDelegate)
    8.   at MyPlug.Start () [0x00000] in D:\Unity\...\Assets\MyPlug.cs:47
    9.  
    partly obfuscated with "...", it could also be that there's a dependency missing?
    I'm currently researching the issue.
     
    Last edited: Aug 15, 2013
  4. akeplinger

    akeplinger

    Joined:
    Oct 26, 2008
    Posts:
    57
    I'm seeing the same problem. DLLs are in the plugin folder and the dlls are working in authoring.
    When an executible is created and run the debug log spits out:

    Fallback handler could not load library C:/..../eyetrack_Data/Mono/QuickLink2.dll
    DllNotFoundException: QuickLink2.dll
    at (wrapper managed-to-native) QuickLink2DotNet.QuickLink2API:QLDevice_Enumerate (int,int[])
    at QuickStart.Initialize.QL2Initialize () [0x00000] in <filename unknown>:0
    at EyeTrack.Start () [0x00000] in <filename unknown>:0


    The <filename unknown> part concerns me.
    On a guess I tried placing the dll that it's looking for into the Mono folder with the same result.
    Puzzled.
    I am compiling on a 64 bit system but I tried 32 and 64 bit builds just in case the dll wasn't 64 bit compliant.

    When I open up the _Data folder I can see the plugins there. Been grinding gears on this for a while.

    Does anybody have any other guesses?
     
  5. soothing

    soothing

    Joined:
    Apr 28, 2013
    Posts:
    6
    I'm seeing the same problem with a small twist. Everything works on one machine including published executable, but I get the "Fallback handler could not load library" problem when I try to run the exe on a separate machine. Both authoring device and problem device have the same specs- Windows desktop PC. Has anyone found a resolution?
     
  6. VolodyaD

    VolodyaD

    Joined:
    Jan 16, 2014
    Posts:
    2
    Hi There!
    I have the same problem.
    I compiled Win32 DLL on Windows 7. This Dll works in Unity Editor and with executable...
    But On other Windows PC fails to load....
    Anyone knows what is the problem?
     
  7. tteneder

    tteneder

    Unity Technologies

    Joined:
    Feb 22, 2011
    Posts:
    175
    @akeplinger ikris: I may have found a solution for you:

    Today I had the same problem ( a couple of "Fallback handler could not load library" followed by a DllNotFoundException), but I found a solution.

    My scenario:

    I try to call a function from dll A which itself depends on dll B. This doesn't work right away, but when I load the depending dlls manually bofore I call the function it works.

    Example code:

    Code (csharp):
    1.  
    2. #define LOAD_DLL_MANUALLY
    3.  
    4. using UnityEngine;
    5. using System;
    6. using System.Collections;
    7. using System.Runtime.InteropServices;
    8.  
    9. public class DllTest : MonoBehaviour {
    10.  
    11.     private IntPtr handleB;
    12.  
    13. #if LOAD_DLL_MANUALLY
    14.     void Awake() {
    15.         //Load
    16.         handleb = LoadLib( <path to B.dll>);
    17.     }
    18.  
    19.     private IntPtr LoadLib( string path ) {
    20.         IntPtr ptr = LoadLibrary( path );
    21.         if (ptr == IntPtr.Zero)
    22.         {
    23.             int errorCode = Marshal.GetLastWin32Error();
    24.             Debug.LogError(string.Format("Failed to load library {1} (ErrorCode: {0})",errorCode, path));
    25.         }else {
    26.             Debug.Log ("loaded lib "+path);
    27.         }
    28.         return ptr;
    29.     }
    30.  
    31.     void OnDestroy() {
    32.         //Free
    33.         if(handleB != IntPtr.Zero)
    34.             FreeLibrary(handleB);
    35.     }
    36. #endif
    37.  
    38.     // Use this for initialization
    39.     void Start () {
    40.         Debug.Log( myExternDllFunction() );
    41.     }
    42.  
    43. #if LOAD_DLL_MANUALLY
    44.     [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
    45.     private static extern IntPtr LoadLibrary(string libname);
    46.    
    47.     [DllImport("kernel32.dll", CharSet = CharSet.Auto)]
    48.     private static extern bool FreeLibrary(IntPtr hModule);
    49. #endif
    50.  
    51.    
    52.     [DllImport("A")]
    53.     private static extern float myExternDllFunction();
    54. }
    55.  
    The more other depending dlls you have, the more you have to load manually upfront. Note: this is for Windows(7). I haven't tried to do that on Mac (yet).

    Also make sure that the dll architecture (32/64 bit) matches the game's build architecture. The Editor itself is 32bit, so be aware that you have to have 32bit libs for testing in the editor.

    You can also try to use Release builds of your dlls (instead of Debug ones). That worked for me some time.

    @the other guys: Seems like you deal with different problems. Let me give a shot at it (only guesswork here):

    @SmoothP: I you get some "Fallback handler could not load library", but no DllNotFoundException it seems like you didn't copy the right dll to the required "Plugins" folder. The Fallback handler then tries to find the right one at other places and eventually succeeds.
    Your game runs, but may not on other machines.
    @soothing Volodya: Same here.

    hth
     
    LaserWzzrd likes this.
  8. VolodyaD

    VolodyaD

    Joined:
    Jan 16, 2014
    Posts:
    2
    Hi.
    I already solved the problem you discussed all the time...
    The reason is that Visual Studio links the created dll with other dll which is related only to Visual Studio software.
    (it's maybe for debug purposes )....
    This causes that created DLL can be only loaded on PC which has installed Visual Studio.

    To avoid this problem do the following steps:
    1) open Visual Studio DLL project.
    2) Go to project properties;
    3) Go to Configuration Properties->C\C++ -> Code Generation.
    4) In the list find the item "Runtime Library". Then change it to be "Multi-Threaded (\MT)"..
    5) Thanks all. reCompile your library....

    The New DLL will be related only to standart windows DLL's.
    That's what you need.
    It will be run on all windows platforms...
     
  9. vferguson

    vferguson

    Joined:
    Oct 15, 2014
    Posts:
    3
    Thanks VolodyaD! This fixes the problem for me.
     
  10. rubendon

    rubendon

    Joined:
    Sep 26, 2017
    Posts:
    2
    Hi, I was faced with the same errors in my project when using SQLite through C# scripts in Unity.
    I found that it worked in the build in editor but not in the run, and changing the .dll file didnt work for me.

    SOLUTION -
    I copied the .dll file into the build folder next to the .exe, I then also copied the .db to this location.
    Then in my code I updated my DB script path from:
    path = "URI=file:"+ "Assets/Plugins/SQLiter/Databases/" + dbName + ".db";
    TO:
    path = "URI=file:"+ dbName + ".db";

    Doing so resolved this problem for me after hours of trying, hope this helps anyone else with the same problem!


    My error was as follows -
     
  11. parkerhg

    parkerhg

    Joined:
    May 18, 2021
    Posts:
    2
    For others who (like me) are searching for why they don't have any issues in their project but do get this error logged anyway, it could be you're using a library that suffers from this (harmless) bug in Unity that hasn't been fixed yet. Here's the link to this bug in the issue tracker: https://issuetracker.unity3d.com/is...tribute-of-a-non-existent-dll-will-log-errors

    as an example, my project used PUN 2 and we'd get many of these messages in our logs. Confirmation from PUN that it is a bug on Unity's side and not theirs: https://forum.photonengine.com/disc...d-library-mono-in-unity-build-project-version
     
  12. MadboyJames

    MadboyJames

    Joined:
    Oct 28, 2017
    Posts:
    262
    I had this issue with FMod plugin, and my issue was as tteneder described.
    I had some volume settings being restored in the first scene on awake... which was too soon.
    I moved my volume setting restore code to on start, and it could now find the dll.
     
  13. TigerHix

    TigerHix

    Joined:
    Oct 20, 2015
    Posts:
    69
    This helped me almost 10 years later. Thank you so much!