Search code examples
c#opencvubuntumonodevelopemgucv

MonoDevelop unable to find shared libs on (L)Ubuntu


Im trying to use EmguCV to do some image processing with MonoDevelop. I can build the project but if I try to debug/run it from inside MonoDevelop, I get a DllNotFoundException saying it cannot find libdl.so. If I run the compiled program directly (with mono emgucv_test.exe) everything works fine.
This is a console app, I got very similar behaviour for a Gtk# test project where it said, it couldnt find libgdiplus.so. I can find both libs however with ldconfig -p |grep libgdiplus.
All of this leads me to believe, that this is neither a problem with missing libs, EmguCV/OpenCV nor mono but with MonoDevelop.

I tried setting the LD_LIBRARY_PATH environment variable in the projects run configuration, that didn't help. I was unable to find anything related online and don't know what else I could try. What is the problem and how can I fix this? This is just a test app, for the real project Im going to need to be able to properly debug with MonoDevelop.

Im running MonoDevelop 6.1.1 (flatpak version) in Lubuntu 16.10 (also tested in Ubuntu 16.04) in a VirtualBox VM and I installed the latest mono (v4.6.1).

Update
I just tested this with MonoDevelop installed with the monodevelop package (version 5.10). With this it works.
I know nothing about flatpak, but I've read somewhere, that it is kind of a sandbox environment for apps. If this is true, could the problems I experience be due to this?


Solution

  • This is basically expected.

    As you theorized, the issue is that FlatPak applications run in a sandbox. FlatPak MonoDevelop can only see:

    • Its own /usr - provided by org.freedesktop.Runtime
    • Its own /app - where everything built for the package goes - e.g. Gtk#, FSharp, libgdiplus, Mono
    • Your home directory
    • /dev, for things like /dev/kvm, if we ever need that for some reason

    It can't see anything outside those locations.

    To explore, you can use flatpak run --command=bash com.xamarin.MonoDevelop which will give you a shell inside the runtime so you can see the actual contents.

    If what you want isn't bundled, you have three choices:

    1. Grab it from NuGet, if it exists there
    2. One way or another, provide it somewhere in /home
    3. Build your own MonoDevelop, sans FlatPak's containerization, and use that instead

    Using a sandbox for GUI apps is a trend in Linux desktop apps, including IDEs (e.g. GNOME Builder has the exact same limitations)