Error requiring luasocket on socket.core file installed through Luarocks on Windows

匿名 (未验证) 提交于 2019-12-03 02:38:01

问题:

System configuration:

OS: Windows 7 x64  lua -v   Lua 5.1.4  luarocks -v   2.2.0beta1  luarocks list   luasocket     3.0rc1-1 (installed) - C:/Program Files (x86)/LuaRocks/systree/lib/luarocks/rocks  luarocks show luasocket    LuaSocket 3.0rc1-1 - Network support for the Lua language      LuaSocket is a Lua extension library that is composed by two parts: a C core     that provides support for the TCP and UDP transport layers, and a set of Lua     modules that add support for functionality commonly needed by applications that     deal with the Internet.      License:        MIT     Homepage:       http://luaforge.net/projects/luasocket/     Installed in:   C:\Program Files (x86)\LuaRocks\systree      Modules:         ltn12 (C:\Program Files (x86)\LuaRocks\systree/share/lua/5.1/ltn12.lua)         mime (C:\Program Files (x86)\LuaRocks\systree/share/lua/5.1/mime.lua)         mime.core (C:\Program Files (x86)\LuaRocks\systree/lib/lua/5.1/mime/core.dll)         socket (C:\Program Files (x86)\LuaRocks\systree/share/lua/5.1/socket.lua)         socket.core (C:\Program Files (x86)\LuaRocks\systree/lib/lua/5.1/socket/core.dll)         socket.ftp (C:\Program Files (x86)\LuaRocks\systree/share/lua/5.1/socket/ftp.lua)         socket.headers (C:\Program Files (x86)\LuaRocks\systree/share/lua/5.1/socket/headers.lua)         socket.http (C:\Program Files (x86)\LuaRocks\systree/share/lua/5.1/socket/http.lua)         socket.smtp (C:\Program Files (x86)\LuaRocks\systree/share/lua/5.1/socket/smtp.lua)         socket.tp (C:\Program Files (x86)\LuaRocks\systree/share/lua/5.1/socket/tp.lua)         socket.url (C:\Program Files (x86)\LuaRocks\systree/share/lua/5.1/socket/url.lua)  luarocks path   SET LUA_PATH=C:\Users\Zequez\AppData\Roaming/luarocks/share/lua/5.1/?.lua;   C:\Users\Zequez\AppData\Roaming/luarocks/share/lua/5.1/?/init.lua;   C:\Program Files (x86)\LuaRocks\systree/share/lua/5.1/?.lua;   C:\Program Files (x86)\LuaRocks\systree/share/lua/5.1/?/init.lua;   C:\Program Files (x86)\LuaRocks\2.2\lua\?.lua;   C:\Program Files (x86)\LuaRocks\2.2\lua\?\init.lua;   SET LUA_CPATH=C:\Users\Zequez\AppData\Roaming/luarocks/lib/lua/5.1/?.dll;   C:\Program Files (x86)\LuaRocks\systree/lib/lua/5.1/?.dll;   .\?.dll;   .\?51.dll;   C:\ProgramFiles (x86)\LuaRocks\2.2\?.dll;   C:\Program Files (x86)\LuaRocks\2.2\?51.dll;   C:\Program Files (x86)\LuaRocks\2.2\clibs\?.dll;   C:\Program Files (x86)\LuaRocks\2.2\clibs\?51.dll;   C:\Program Files (x86)\LuaRocks\2.2\loadall.dll;   C:\Program Files (x86)\LuaRocks\2.2\clibs\loadall.dll       SET LUA_CPATH=C:\Users\Zequez\AppData\Roaming/luarocks/lib/lua/5.1/?.dll;   C:\Program Files (x86)\LuaRocks\systree/lib/lua/5.1/?.dll;   .\?.dll;   .\?51.dll;   C:\Program Files (x86)\LuaRocks\2.2\?.dll;   C:\Program Files (x86)\LuaRocks\2.2\?51.dll;   C:\Program Files (x86)\LuaRocks\2.2\clibs\?.dll;   C:\Program Files (x86)\LuaRocks\2.2\clibs\?51.dll;   C:\Program Files (x86)\LuaRocks\2.2\loadall.dll;   C:\Program Files (x86)\LuaRocks\2.2\clibs\loadall.dll 

I'm new to Lua, and I'm not used to compiling stuff on Windows.

Anyway the installaion of luasocket finished without errors, compiling all the stuff with MS Visual Studio 2010. Had to run luarocks from the Visual Studio Command Prompt, but it finally worked.

But when I try to require it, I drive into an error.

Using require 'luarocks.loader' doesn't help either, same error. I think I don't need it anyway, because I have LUA_PATH set up with the luarocks paths

I searched for hours with no results. I also tried to install an older version of Luasockets but it requires Visual Studio 2003, so I would like to avoid that.

回答1:

It looks like Lua is trying to parse the DLL as Lua code. This can happen if package.path (or the LUA_PATH environment variable) contains ?.dll path templates. Please remove all ?.dll templates from package.path and put them into package.cpath (or the LUA_CPATH environment variable).



易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!