IfSharp icon indicating copy to clipboard operation
IfSharp copied to clipboard

Mac OS DllNotFoundException (.NET Core)

Open 7Grok opened this issue 5 years ago • 6 comments

Hi

I am trying to load a managed DLL that wraps an unmanaged .so or .dylib on Mac OS

If I create a CLI app using dotnet I can get it to work if I copy to DLL and the .dylib into the output folder. As an FYI I have to rename the .so to .dylib

If I create a simple test script in ifSharp

#r "managed_wrapper.dll"
open System
open LibraryName

let main =
    Library.some_init_function(0) |> ignore
    printfn "Hello World from F#!"
    0

main

I get DllNotFoundException even though the DLL and the .dylib are in the same folder where I execute jupyter notebook

I have tried

  • Putting .so and .dylib in the same folder
  • setting DYLD_LIBRARY_PATH
  • Various options from http://christoph.ruegg.name/blog/loading-native-dlls-in-fsharp-interactive.html

Related information

  • Operating system: Mac OS 10.14.6
  • jupyter core : 4.6.1
  • jupyter-notebook : 6.0.2
  • jupyter client : 5.3.4
  • jupyter lab : 1.2.3
  • dotnet: 2.1.401

7Grok avatar Dec 24 '19 03:12 7Grok

Interesting, OK so first thing the .NET Core version is still very experimental I've never actually tried using native libraries with it myself.

I have been able to do something similar using Mono on macOS: https://github.com/cgravill/interactiveComputingFSharpJupyter/blob/master/FOSDEM/07_TensorflowSharp.ipynb

Just to repeat, I've not done this on .NET Core at all Windows or macOS. Now there's a new LTS version of .NET Core out I'll try upgrading /master to that and see how things are.

cgravill avatar Dec 24 '19 08:12 cgravill

Yes it looks to work fine on Windows with the present version: image

macOS I run into issues. This will probably need a volunteer with more experience in debugging macOS and .NET Core interactions.

I'm working on an update to .NET Core 3.1 here: #244

cgravill avatar Dec 24 '19 10:12 cgravill

Another option is the new general .NET Kernel: https://www.hanselman.com/blog/AnnouncingNETJupyterNotebooks.aspx

I'm working on this with others there. It doesn't yet have all the features this implementation has but the .NET Core support is much more stable, and has a much nicer way to install packages (including native).

cgravill avatar Dec 24 '19 10:12 cgravill

The new general .NET Kernel works. Thanks !! :)

When you say its missing features is there someplace I can see whats missing? I don't really need much, charting, displaying images and loading a few packages.

Also for anyone that finds this, I also posted a StackOverflow with what I had to do to get a console app working.

Once Again Thanks.

--

7Grok avatar Dec 24 '19 14:12 7Grok

It'd be good to see the the feature diff - A big one missing is a nicer way to do LaTeX that is prototyped here: https://github.com/dotnet/try/pull/692

cartermp avatar Dec 24 '19 20:12 cartermp

This will be incomplete... the big things I'm aware of:

In IFSharp but not the .NET Kernel:

  • Code completion, we're talking about how we might get Monaco in.
  • .NET Framework / Mono (may not be desirable long-term but some libraries haven't been ported)
  • More libraries made to work e.g. GoogleCharts (I think @colombod may be adding that), https://github.com/predictionmachines/InteractiveDataDisplay and streamed computational expressions

Conversely in .NET Kernel

  • new syntax to #r dependencies, this is so much better
  • Solid .NET Core support, I believe cross-platform
  • Cross language connections e.g. to JavaScript and C#

There's no plans to stop IFSharp but I'd really like to transition efforts over time to the shared .NET Kernel. The main thing for me is basic code completion which we're talking about - I had a mini prototype, and I understand others have done more, but the current code editor experience (CodeMirror) in the .NET Kernel isn't great in either F# or C#.

cgravill avatar Dec 31 '19 13:12 cgravill