Question

I've created ASP.NET MVC project in MonoDevelop on Ubuntu.
Using Nuget, I added LibGit2Sharp package, but it doesn't have libgit2 library compiled for linux environment.
Then I downloaded libgit2 sources and compiled them.
Now I have libgit2-06d772d.so, but when I put it into the bin folder of my asp.net mvc project, I get System.DllNotFoundException git2-06d772d

NOTE
When I create Console project and put libgit2-06d772d.so into the bin folder of this project, application works fine.

Was it helpful?

Solution

Shared objects are not loaded when they are next to a particular file, but when their directory is in the library load path. The operating system sets a few paths that are valid for all programs, but if you have your library elsewhere, you need to specify the directory yourself.

Exporting LD_LIBRARY_PATH with the dir of the library will let the library loader know what other paths you expect to load a library from. E.g. if you built libgit2 with the libgit2sharp script you might run

export LD_LIBRARY_PATH=$HOME/libgit2sharp/libgit2/build

in the console to let the OS know that any program you start from that shell where to find libgit2.

It's common for mono-based apps to provide a script for the user to run which sets up the environment before calling mono to start the actual .exe with the program.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top