zeromq / lzmq

Lua binding to ZeroMQ
MIT License
136 stars 46 forks source link

Error loading module 'lzmq'... The specified module could not be found #50

Closed sjpritchard closed 7 years ago

sjpritchard commented 7 years ago

When trying to load lzmq in lua, I receive the following error:

error loading module 'lzmq' from file 'C:\Users\Steve\luatest\lua\lib\lua\5.1\lzmq.dll': The specified module could not be found.

I am running Lua 5.1.5 x64 on Windows 10. (I need this specific version as I'm modding a game that uses it). I have installed lzmq via luarocks into a custom tree folder, and have specified the correct path and cpath in my interpreter. I am using the following Windows ZMQ library: http://miru.hk/archive/ZeroMQ-4.0.4~miru1.0-x64.exe. I had to rename libzmq-v120-mt-4_0_4.lib to libzmq.lib so that luarocks could find it during the install and compilation.

It successfully compiles (with some warnings) using the x64 Native Tools Command Prompt for VS 2017:

C:\Users\Steve\luatest>luarocks install lzmq --tree lua ZMQ_DIR=C:\Users\Steve\luatest\zmq
Installing https://luarocks.org/lzmq-0.4.3-1.src.rock
cl /nologo /MD /O2 -c -Fosrc/lzmq.obj -IC:/Program Files/lua-5.1.5/include src/lzmq.c -DLUAZMQ_USE_SEND_AS_BUF -DLUAZMQ_USE_TEMP_BUFFERS -DLUAZMQ_USE_ERR_TYPE_OBJECT -IC:\Users\Steve\luatest\zmq/include
lzmq.c
cl /nologo /MD /O2 -c -Fosrc/lzutils.obj -IC:/Program Files/lua-5.1.5/include src/lzutils.c -DLUAZMQ_USE_SEND_AS_BUF -DLUAZMQ_USE_TEMP_BUFFERS -DLUAZMQ_USE_ERR_TYPE_OBJECT -IC:\Users\Steve\luatest\zmq/include
lzutils.c
cl /nologo /MD /O2 -c -Fosrc/poller.obj -IC:/Program Files/lua-5.1.5/include src/poller.c -DLUAZMQ_USE_SEND_AS_BUF -DLUAZMQ_USE_TEMP_BUFFERS -DLUAZMQ_USE_ERR_TYPE_OBJECT -IC:\Users\Steve\luatest\zmq/include
poller.c
cl /nologo /MD /O2 -c -Fosrc/zcontext.obj -IC:/Program Files/lua-5.1.5/include src/zcontext.c -DLUAZMQ_USE_SEND_AS_BUF -DLUAZMQ_USE_TEMP_BUFFERS -DLUAZMQ_USE_ERR_TYPE_OBJECT -IC:\Users\Steve\luatest\zmq/include
zcontext.c
cl /nologo /MD /O2 -c -Fosrc/zerror.obj -IC:/Program Files/lua-5.1.5/include src/zerror.c -DLUAZMQ_USE_SEND_AS_BUF -DLUAZMQ_USE_TEMP_BUFFERS -DLUAZMQ_USE_ERR_TYPE_OBJECT -IC:\Users\Steve\luatest\zmq/include
zerror.c
cl /nologo /MD /O2 -c -Fosrc/zmsg.obj -IC:/Program Files/lua-5.1.5/include src/zmsg.c -DLUAZMQ_USE_SEND_AS_BUF -DLUAZMQ_USE_TEMP_BUFFERS -DLUAZMQ_USE_ERR_TYPE_OBJECT -IC:\Users\Steve\luatest\zmq/include
zmsg.c
cl /nologo /MD /O2 -c -Fosrc/zpoller.obj -IC:/Program Files/lua-5.1.5/include src/zpoller.c -DLUAZMQ_USE_SEND_AS_BUF -DLUAZMQ_USE_TEMP_BUFFERS -DLUAZMQ_USE_ERR_TYPE_OBJECT -IC:\Users\Steve\luatest\zmq/include
zpoller.c
cl /nologo /MD /O2 -c -Fosrc/zsocket.obj -IC:/Program Files/lua-5.1.5/include src/zsocket.c -DLUAZMQ_USE_SEND_AS_BUF -DLUAZMQ_USE_TEMP_BUFFERS -DLUAZMQ_USE_ERR_TYPE_OBJECT -IC:\Users\Steve\luatest\zmq/include
zsocket.c
link -dll -def:lzmq.def -out:lzmq.dll C:/Program Files/lua-5.1.5/lua5.1.lib src/lzmq.obj src/lzutils.obj src/poller.obj src/zcontext.obj src/zerror.obj src/zmsg.obj src/zpoller.obj src/zsocket.obj -libpath:C:\Users\Steve\luatest\zmq/lib libzmq.lib
Microsoft (R) Incremental Linker Version 14.10.25019.0
Copyright (C) Microsoft Corporation.  All rights reserved.

lzmq.obj : warning LNK4197: export 'luaopen_lzmq' specified multiple times; using first specification
   Creating library lzmq.lib and object lzmq.exp
LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library
cl /nologo /MD /O2 -c -Fosrc/ztimer.obj -IC:/Program Files/lua-5.1.5/include src/ztimer.c
ztimer.c
cl /nologo /MD /O2 -c -Fosrc/lzutils.obj -IC:/Program Files/lua-5.1.5/include src/lzutils.c
lzutils.c
link -dll -def:timer.def -out:lzmq/timer.dll C:/Program Files/lua-5.1.5/lua5.1.lib src/ztimer.obj src/lzutils.obj
Microsoft (R) Incremental Linker Version 14.10.25019.0
Copyright (C) Microsoft Corporation.  All rights reserved.

ztimer.obj : warning LNK4197: export 'luaopen_lzmq_timer' specified multiple times; using first specification
   Creating library lzmq/timer.lib and object lzmq/timer.exp
LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library
No existing manifest. Attempting to rebuild...
lzmq 0.4.3-1 is now installed in C:/Users/Steve/luatest/lua (license: MIT/X11)

My failing test is below. It can definitely find the dll file because it throws a different error if I rename the dll file.

PS C:\Users\Steve\luatest> lua5.1.exe
Lua 5.1.5  Copyright (C) 1994-2012 Lua.org, PUC-Rio
> package.path = package.path..";C:\\Users\\Steve\\luatest\\lua\\share\\lua\\5.1\\?.lua"
> package.cpath = package.cpath..";C:\\Users\\Steve\\luatest\\lua\\lib\\lua\\5.1\\?.dll"
> local zmq = require("lzmq")
error loading module 'lzmq' from file 'C:\Users\Steve\luatest\lua\lib\lua\5.1\lzmq.dll':
        The specified module could not be found.

stack traceback:
        [C]: ?
        [C]: in function 'require'
        stdin:1: in main chunk
        [C]: ?
sjpritchard commented 7 years ago

FIXED: I didn't have the Windows libzmq.dll file in my search path!! Duh!

moteus commented 7 years ago

Just litle suggestion. Do not messup with runtime versions. You use libzmq.dll with static linked runtime from MSVC 2012. But build lzmq.dll with dinamic linked runtime. It can produce some problems. (but may be and it will works) I faced problem when compile zmq with MSVC 2008 and lzmq with MSVC 2010. This 2 compilers produse different values for error codes. So it will no possible to know what error is generated.

sjpritchard commented 7 years ago

Thanks for the advice moteus! :)