zeromq / clrzmq4

ZeroMQ C# namespace (.NET and mono, Windows, Linux and MacOSX, x86 and amd64)
GNU Lesser General Public License v3.0
241 stars 112 forks source link

Shared library issues with DotNet Core 2.1 under Linux #180

Open daniel-sherwood opened 5 years ago

daniel-sherwood commented 5 years ago

Hi

I'm trying to use 4.1.0.31 this with DotNet Core 2.1 under Linux and get the following error at startup.

Unhandled Exception: System.TypeInitializationException: The type initializer for 'ZeroMQ.lib.zmq' threw an exception. ---> System.DllNotFoundException: Unable to load shared library '__Internal' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: lib__Internal: cannot open shared object file: No such file or directory

Is this supposed to work?

Cheers

Daniel

cezarypiatekGC commented 4 years ago

It looks like Platform.LoadUnmanagedLibrary() is not called for NetStandard and .NET Core https://github.com/zeromq/clrzmq4/blob/6f193f3993c7e2f42ba823c2a85a1e7ba597eda2/Platform/zmq.cs#L32

I was able to make it work by putting the native library in the same folder as the main app (not in the architecture subfolder as it was for full framework).

EDIT: You can also fix the issue by manually installing libzmq3-dev package on the linux machine:

echo 'deb http://download.opensuse.org/repositories/network:/messaging:/zeromq:/release-stable/Debian_10/ /' > /etc/apt/sources.list.d/network:messaging:zeromq:release-stable.list 
wget -nv https://download.opensuse.org/repositories/network:messaging:zeromq:release-stable/Debian_10/Release.key -O Release.key 
apt-key add - < Release.key 
apt-get -y update
apt-get -y install libzmq3-dev=4.3.2