在Windows上通过Luarocks安装的socket.core文件上要求luasocket时出错 [英] Error requiring luasocket on socket.core file installed through Luarocks on Windows

查看:945
本文介绍了在Windows上通过Luarocks安装的socket.core文件上要求luasocket时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

系统配置:

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

我是Lua的新手,而且我不习惯在Windows上编译东西.

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

无论如何,luasocket的安装均无错误,使用MS Visual Studio 2010编译了所有内容.必须从Visual Studio命令提示符运行luarocks,但最终成功了.

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.

> require 'socket'
error loading module 'socket.core' from file 'C:\Program Files (x86)\LuaRocks\systree/lib/lua/5.1/socket\core.dll':
        C:\Program Files (x86)\LuaRocks\systree/lib/lua/5.1/socket\core.dll:1: '=' expected near 'É'
stack traceback:
        [C]: ?
        [C]: in function 'require'
        ...iles (x86)\LuaRocks\systree/share/lua/5.1/socket.lua:12: in main chunk
        [C]: in function 'require'
        stdin:1: in main chunk
        [C]: ?

使用require 'luarocks.loader'也无济于事,出现同样的错误.我想我还是不需要它,因为我已经使用luarocks路径

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

我搜索了数小时却没有结果.我还尝试安装一个旧版本的Luasockets,但是它需要Visual Studio 2003,所以我想避免这种情况.

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.

推荐答案

Lua似乎试图将DLL解析为Lua代码.如果package.path(或LUA_PATH环境变量)包含?.dll路径模板,则可能发生这种情况.请从package.path中删除所有?.dll模板,并将它们放入package.cpath(或LUA_CPATH环境变量).

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).

这篇关于在Windows上通过Luarocks安装的socket.core文件上要求luasocket时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆