Azure-Samples / MipSDK-File-Dotnet

MIT License
5 stars 4 forks source link

Unable to run the example in Ubuntu 20.04 - LoadLibrary failed for libmip_dotnet.so #2

Open lgiuliani80 opened 2 years ago

lgiuliani80 commented 2 years ago

I always get this error when trying to run ./mipsdk under Ubuntu 20.04.

Unhandled exception. System.ComponentModel.Win32Exception (0x80004005): LoadLibrary failed for: [/home/<sanitized>/mip-filesdk-dotnet-core/bin/Debug/libmip_dotnet.so]
   at Microsoft.InformationProtection.Utils.SafeNativeMethods.LoadLibrary(String dllToLoad)
   at Microsoft.InformationProtection.Utils.Loader.LoadDlls(String dllFolder, String dllName, String[] dllDependencies)
   at Microsoft.InformationProtection.MIP.Initialize(MipComponent mipComponent, String path)
   at Microsoft.InformationProtection.MIP.CreateMipContext(MipConfiguration mipConfiguration)
   at mipsdk.Action..ctor(ApplicationInfo appInfo) in /home/<sanitized>/mip-filesdk-dotnet-core/src/Action.cs:line 86
   at mipsdk.Program.Main(String[] args) in /home/<sanitized>/mip-filesdk-dotnet-core/src/Program.cs:line 35
Aborted

The error persists if migrating to .NET 6 and happens in general with every .NET application trying to use Microsoft.InformationProtection.File under Ubuntu 20.04.

Minimal steps to reproduce

sudo apt-get install scons libgsf-1-dev libssl-dev libsecret-1-dev freeglut3-dev libcpprest-dev libcurl3-dev uuid-dev
git clone https://github.com/Azure-Samples/mip-filesdk-dotnet-core.git
# change the PackageReference to Microsoft.InformationProtection.File.Ubuntu2004 in mipsdk.csproj
dotnet build --output ../bin/Debug   [from src]
cd ../bin/Debug
./mipsdk
wangfu91 commented 1 year ago

I'm running into the very same problem on Ubuntu 20.04, @lgiuliani80 have you found any solution yet?

I also tried on Ubuntu 18.04 (with package Microsoft.InformationProtection.File.Ubuntu1804), but still had the same issue.

I can confirm that all the MIP SDK dependencies stated in the README.md have been installed.

@tommoser since you are the author of this code sample, would you mind taking a look? Thanks!

lgiuliani80 commented 1 year ago

I'm running into the very same problem on Ubuntu 20.04, @lgiuliani80 have you found any solution yet?

I also tried on Ubuntu 18.04 (with package Microsoft.InformationProtection.File.Ubuntu1804), but still had the same issue.

I can confirm that all the MIP SDK dependencies stated in the README.md have been installed.

@tommoser since you are the author of this code sample, would you mind taking a look? Thanks!

Unfortunately not. At the moment I solved switching to Java. The Java wrapper for MIP SDK does work on Linux Ubuntu 20.04.

lgiuliani80 commented 1 year ago

I can add that I investigated the issue and found out that the root cause is libmip_dotnet.so referencing unexisting symbols which are supposed to be, presumably, in libmip_file_sdk.so . You can test yourself with this small C snippet:

#include <unistd.h>
#include <dlfcn.h>
#include <stdio.h>

int main() {

        int h = dlopen("./libmip_dotnet.so", RTLD_NOW);

        printf("h = %d, err = %s\n", h, dlerror());
        return 0;
}

The result of the execution is:

h = 0, err = ./libmip_dotnet.so: undefined symbol: _ZN5mipns13FileLabelInfo13GetPropertiesERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKSt10shared_ptrINS_10MipContextEERKS9_IvE
amusleh-spotware-com commented 1 year ago

We have the some exact issue, please can you help us?

wangfu91 commented 1 year ago

@afhacker 1.11.64 and older version of the Microsoft.InformationProtection.File.Ubuntu2004 package works, can be used as a workaround for now.

amusleh-spotware-com commented 1 year ago

@afhacker 1.11.64 and older version of the Microsoft.InformationProtection.File.Ubuntu2004 package works, can be used as a workaround for now.

Yeah, we were able to make it work with version 1.11.64.

Hopefully they release a new version of SDK for .NET which is not a wrapper over C++ SDK and doesn't require separate packages for Linux and Windows and extra packages installation on Linux.