Search Unity

Linux build is putting libNative.so in wrong place

Discussion in 'Linux' started by mattleibow, Sep 24, 2017.

  1. mattleibow

    mattleibow

    Joined:
    Sep 24, 2017
    Posts:
    2
    I am new to this Unity world, so I might be doing something wrong...

    But, I am getting a DllNotFoundException for my Linux build. The Windows and MacOS build work fine, so it is not my managed code. The Linux library works fine in other .NET apps, so it is not that. And finally, when I look at the error message and move my native library to the location it is looking in, the game works.

    Basically, this is a simple game that creates a 2D texture using SkiaSharp. My p/invoke looks like this (SKColorType is an enumeration):

    Code (CSharp):
    1. [DllImport("libSkiaSharp", CallingConvention = CallingConvention.Cdecl)]
    2. public extern static SKColorType sk_colortype_get_default_8888();
    I have all of this on GitHub: https://github.com/mattleibow/SkiaSharpUnityDemo
    The log files:
    - console log: https://gist.github.com/mattleibow/b6e95312ada816496cd8afbcae36f8b1
    - player log: https://gist.github.com/mattleibow/3f76cef131cf71abe8ca47d109806580

    SkiaSharp: https://github.com/mono/SkiaSharp
     
  2. Tak

    Tak

    Unity Technologies

    Joined:
    Mar 8, 2010
    Posts:
    950
    Hi,
    Sorry for the delayed response - I put this onto my list of things to investigate, and then it was now.
    What's going on here is that linux expects libraries to be "libSomething.so" - so since you're importing libSkiaSharp instead of SkiaSharp, it's looking for liblibSkiaSharp.so

    I'll add a fallback for this case, but in the meantime, you can work around it by renaming the native linux plugin in your project.
     
  3. mattleibow

    mattleibow

    Joined:
    Sep 24, 2017
    Posts:
    2
    Thanks! Everything is now working.

    While we are hanging out with the natives, is there a reason why Unity can't understand that a .dylib is a mac library? I can rename the native file to .bundle and do things, but not a .dylib.