DllNotFoundException: libzmq
Asked Answered
J

3

6

I'm trying to use ZeroMQ C#-binding ( http://www.zeromq.org/bindings:clr ) for communicating with a server for a game I'm creating in Unity (I'm using Mac OS X 10.8). I therefore created a simple function that connects to a server, sends a message and then receives a message:

using UnityEngine;
using System.Runtime.InteropServices;
using System.Collections;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ZeroMQ;



public class NetworkZero : MonoBehaviour {

    // Use this for initialization
    public static NetworkZero instance; 

    void Start () {
        instance = this;
        Debug.Log("START NETWORK COMMUNICATION");
    }


    // Update is called once per frame
    void Update () {
        using (ZMQ.Context context = new ZMQ.Context(1))
            using (ZMQ.Socket client = context.Socket(ZMQ.SocketType.REQ))
            {
                 string sendMSG = "CLIENT";
                 client.Connect("tcp://localhost:31415");
                 client.Bind("tcp://localhost:31415");
                 client.Send(sendMSG, Encoding.Unicode);
                 string message = client.Recv(Encoding.Unicode);
                 Debug.Log("Received request: " + message);
            }
    }
}

I followed the instructions to include the necessary libraries in my project and in monoDevelop added references to these libraries. But while the program builds, I still get the following error when I try to run the program:

DllNotFoundException: libzmq
ZMQ.Context..ctor (Int32 io_threads)
NetworkZero.Update () (at Assets/SLIP/NetworkZero.cs:26)

Does anyone have any suggestions?

Jillianjillie answered 12/11, 2012 at 16:8 Comment(0)
S
0

Ensure you have set 'Copy Local' to true for the referenced assembly.

Sialagogue answered 12/11, 2012 at 16:10 Comment(1)
I checked and for all referenced assemblies, 'Copy Local' is set to true.Jillianjillie
G
0

When I've added dlls, I've always added them into Unity (drag and drop them somewhere), and then Unity has done some magic and regenerated the IDE project files with the references all correct.

Another stab in the dark - if those libraries do interop stuff, you may need them to be in a folder "Plugins" (may need to be directly under assets, "Assets/Plugins", not tested). Plugins are a pro only feature of Unity though, and they don't work on web apps.

Generate answered 14/11, 2012 at 15:18 Comment(0)
S
0

I've received this in the past when trying to use a 64bit dll in a 32bit application. You mentioned it's working in the editor (which is 64bit) but no in the build, may I suggest you double check that your architecture matches that of the ZeroMQ library? To do this go [Unity] > File > Build Settings then under Architecture, choose x86_64.

enter image description here

Sideshow answered 22/4, 2017 at 10:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.