Zstandard.Net icon indicating copy to clipboard operation
Zstandard.Net copied to clipboard

Linux support

Open vbelot opened this issue 6 years ago • 8 comments

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

vbelot avatar Aug 19 '18 10:08 vbelot

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.

bp74 avatar Aug 19 '18 13:08 bp74

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

vbelot avatar Aug 22 '18 07:08 vbelot

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 :)

bp74 avatar Aug 22 '18 19:08 bp74

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.

simplexidev avatar Aug 22 '18 22:08 simplexidev

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

ChrisMcKee avatar Feb 01 '19 16:02 ChrisMcKee

Thanks, this looks interessting!

bp74 avatar Feb 03 '19 22:02 bp74

any progress?

RouR avatar Aug 03 '20 12:08 RouR

@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.

ChrisMcKee avatar Aug 03 '20 16:08 ChrisMcKee