bp74 / Zstandard.Net

A Zstandard wrapper for .Net
Other
135 stars 26 forks source link

Linux support #6

Open vbelot opened 5 years ago

vbelot commented 5 years ago

Hi bp74,

Currently I am using your lib, which is Windows only for now. So I am stuck using a Windows IIS server. I plan to migrate to CentOS server. Do you plan to embed the Linux library anytime soon ? I don't really know how complicated it would be to implement.

Kind regards

bp74 commented 5 years ago

Hi,

Unfortunately i'm not an expert when it comes to Linux, but i think there is no way to put the native binary to the ZStandard.Net Nuget package since different Linux distributions use different packages.

For CentOs you could try to install this: https://centos.pkgs.org/6/epel-testing-x86_64/zstd-1.3.5-1.el6.x86_64.rpm.html

It would be interessting to know if it works by just installing this CentOs package. Please keep me posted.

vbelot commented 5 years ago

Hi, thanks for your quick reply. I have libzstd installed:

ldconfig -p | grep libzstd
        libzstd.so.1 (libc6,x86-64) => /lib64/libzstd.so.1

However it fails finding the library:

fail: Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware[1]
An unhandled exception has occurred while executing the request.
System.DllNotFoundException: Unable to load shared library 'libzstd' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: liblibzstd: cannot open shared object file: No such file or directory
at Zstandard.Net.ZstandardInterop.ZSTD_DStreamInSize()
at Zstandard.Net.ZstandardStream..ctor(Stream stream, CompressionMode mode, Boolean leaveOpen)

Seems to load if I create a symlink in the app folder though: sudo ln -s /lib64/libzstd.so.1 libzstd.so

bp74 commented 5 years ago

Okay that's interessting. The question is how we can tell .Net to search for the library in the right folder. All suggestions are welcome :)

simplexidev commented 5 years ago

Try NativeLibraryLoader. It fixed that problem for me, and allows for multiple locations since it checks each of them until it finds the dll. This would allow cross-platform builds too. My project uses it to find the library for each OS, and load it. I can submit a pull that could incorporate it.

ChrisMcKee commented 5 years ago

Probably worth looking at https://github.com/CoreyKaylor/Lightning.NET/tree/master/src/LightningDB which has to deal with the same issue.

bp74 commented 5 years ago

Thanks, this looks interessting!

RouR commented 3 years ago

any progress?

ChrisMcKee commented 3 years ago

@RouR see https://github.com/bp74/Zstandard.Net/pull/14 it works but where .net tries to load the libs from is unreliable cross- distro.