dingmaotu / mql-zmq

ZMQ binding for the MQL language (both 32bit MT4 and 64bit MT5)
Apache License 2.0
544 stars 298 forks source link

Cannot load 'libzmq.dll' [126] #17

Closed ChaddersCheese closed 6 years ago

ChaddersCheese commented 6 years ago

Whenever I try and run the below script, I get the error: Cannot load 'libzmq.dll' [126]

The file libzmq.dll is everywhere in my bindings, so it's not that the file does not exist.

Somebody else (maybe) seems to be having a similar issue here: https://www.mql5.com/en/forum/104158

Any ideas???

#include <Zmq/Zmq.mqh>
//+------------------------------------------------------------------+
//| Hello World client in MQL                                        |
//| Connects REQ socket to tcp://localhost:5555                      |
//| Sends "Hello" to server, expects "World" back                    |
//+------------------------------------------------------------------+
void OnInit()
  {
   Comment("Started");
// Prepare our context and socket
   Context context("helloworld");
   Socket socket(context,ZMQ_REQ);

   Print("Connecting to hello world server…");
   socket.connect("tcp://*:5555");

// Do 10 requests, waiting each time for a response
   for(int request_nbr=0; request_nbr!=10 && !IsStopped(); request_nbr++)
     {
      ZmqMsg request("Hello");
      PrintFormat("Sending Hello %d...",request_nbr);
      socket.send(request);

      // Get the reply.
      ZmqMsg reply;
      socket.recv(reply);
      PrintFormat("Received World %d",request_nbr);
     }
  }
dingmaotu commented 6 years ago

Can you give me your environment detail? Like your OS, your CPU architecture, your MetaTrader version, etc.

ChaddersCheese commented 6 years ago

Thanks Ding. I am on Windows 10, 64 bit, MT4 and MetaEditor 4.

I could try this on a virtual machine. If this is your recommendation, which OS would be best?

dingmaotu commented 6 years ago

Hi, make sure that 1. you are using 32bit DLL; 2. the DLL is compiled on Windows with VC++ 2015, you should have vc2015 runtime installed. Can you verify the two points?

ChaddersCheese commented 6 years ago

Hi Ding. Here's a summary of what I've done so far:

Installed ZeroMQ and Pyzmq using the 64 bit download from the following: https://github.com/MrYsLab/xideco/wiki/Installing-ZeroMQ-On-Windows

Also PIP installed Pyzmq.

Copied and pasted all your bindings into the equivalent folders on my computer. These all went in to "C:\Users\User\AppData\Roaming\MetaQuotes\Terminal\61007F7......\MQL4". I copied and pasted the libzmq.dll file from your 'MT4' folder into my 'Libraries' folder.

When I wrote this originally, I had: MQL4\Libraries\MT4\libzmq.dll = Error: 'Cannot load 'libzmq.dll' [126]' But this has now been changed to: MQL4\Libraries\libzmq.dll = New error: 'MQL4\Libraries\libzmq.dll is not 32-bit version' But I definitely downloaded the version in your MT4 folder.

I can confirm I have Microsoft Visual C++ 2015 Redistributable (x64) - 14.0.23918 installed.

I have a strong suspicion that I am missing something simple, especially considering ZeroMQ's installation procedure seems so complicated (I haven't followed these instructions): http://zeromq.org/docs:windows-installations

Thanks again, Anthony

dingmaotu commented 6 years ago

You should have only one 32bit libzmq.dll in your path and libsodium.dll is also needed. And the vc2015 redistributable should be 32bit, too.

ChaddersCheese commented 6 years ago

This is now working. No errors when I git cloned the dlls.

Thanks for all your help. Anthony

dingmaotu commented 6 years ago

@ChaddersCheese you are welcome. Then this issue will be closed.

jothism commented 3 years ago

Traceback (most recent call last): File "c:\users\jothinath\appdata\local\programs\python\python39\lib\runpy.py", line 197, in _run_module_as_main return _run_code(code, main_globals, None, File "c:\users\jothinath\appdata\local\programs\python\python39\lib\runpy.py", line 87, in _run_code exec(code, run_globals) File "C:\Users\Jothinath\AppData\Local\Programs\Python\Python39\Scripts\jupyter-notebook.EXE__main.py", line 4, in File "c:\users\jothinath\appdata\local\programs\python\python39\lib\site-packages\notebook\notebookapp.py", line 51, in from zmq.eventloop import ioloop File "c:\users\jothinath\appdata\local\programs\python\python39\lib\site-packages\zmq\init.py", line 50, in _load_libzmq() File "c:\users\jothinath\appdata\local\programs\python\python39\lib\site-packages\zmq\init__.py", line 28, in _load_libzmq from . import libzmq ImportError: DLL load failed while importing libzmq: The specified module could not be found.

maoyongsheng commented 2 years ago

You should have only one 32bit libzmq.dll in your path and libsodium.dll is also needed. And the vc2015 redistributable should be 32bit, too.

请问macos环境怎么办,m1芯片的