在 Windows 上通过 Luarocks 安装的 socket.core 文件上要求 luasocket 时出错 [英] Error requiring luasocket on socket.core file installed through Luarocks on Windows
问题描述
系统配置:
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)LuaRockssystree
Modules:
ltn12 (C:Program Files (x86)LuaRockssystree/share/lua/5.1/ltn12.lua)
mime (C:Program Files (x86)LuaRockssystree/share/lua/5.1/mime.lua)
mime.core (C:Program Files (x86)LuaRockssystree/lib/lua/5.1/mime/core.dll)
socket (C:Program Files (x86)LuaRockssystree/share/lua/5.1/socket.lua)
socket.core (C:Program Files (x86)LuaRockssystree/lib/lua/5.1/socket/core.dll)
socket.ftp (C:Program Files (x86)LuaRockssystree/share/lua/5.1/socket/ftp.lua)
socket.headers (C:Program Files (x86)LuaRockssystree/share/lua/5.1/socket/headers.lua)
socket.http (C:Program Files (x86)LuaRockssystree/share/lua/5.1/socket/http.lua)
socket.smtp (C:Program Files (x86)LuaRockssystree/share/lua/5.1/socket/smtp.lua)
socket.tp (C:Program Files (x86)LuaRockssystree/share/lua/5.1/socket/tp.lua)
socket.url (C:Program Files (x86)LuaRockssystree/share/lua/5.1/socket/url.lua)
luarocks path
SET LUA_PATH=C:UsersequezAppDataRoaming/luarocks/share/lua/5.1/?.lua;
C:UsersequezAppDataRoaming/luarocks/share/lua/5.1/?/init.lua;
C:Program Files (x86)LuaRockssystree/share/lua/5.1/?.lua;
C:Program Files (x86)LuaRockssystree/share/lua/5.1/?/init.lua;
C:Program Files (x86)LuaRocks2.2lua?.lua;
C:Program Files (x86)LuaRocks2.2lua?init.lua;
SET LUA_CPATH=C:UsersequezAppDataRoaming/luarocks/lib/lua/5.1/?.dll;
C:Program Files (x86)LuaRockssystree/lib/lua/5.1/?.dll;
.?.dll;
.?51.dll;
C:ProgramFiles (x86)LuaRocks2.2?.dll;
C:Program Files (x86)LuaRocks2.2?51.dll;
C:Program Files (x86)LuaRocks2.2clibs?.dll;
C:Program Files (x86)LuaRocks2.2clibs?51.dll;
C:Program Files (x86)LuaRocks2.2loadall.dll;
C:Program Files (x86)LuaRocks2.2clibsloadall.dll
SET LUA_CPATH=C:UsersequezAppDataRoaming/luarocks/lib/lua/5.1/?.dll;
C:Program Files (x86)LuaRockssystree/lib/lua/5.1/?.dll;
.?.dll;
.?51.dll;
C:Program Files (x86)LuaRocks2.2?.dll;
C:Program Files (x86)LuaRocks2.2?51.dll;
C:Program Files (x86)LuaRocks2.2clibs?.dll;
C:Program Files (x86)LuaRocks2.2clibs?51.dll;
C:Program Files (x86)LuaRocks2.2loadall.dll;
C:Program Files (x86)LuaRocks2.2clibsloadall.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)LuaRockssystree/lib/lua/5.1/socketcore.dll':
C:Program Files (x86)LuaRockssystree/lib/lua/5.1/socketcore.dll:1: '=' expected near 'É'
stack traceback:
[C]: ?
[C]: in function 'require'
...iles (x86)LuaRockssystree/share/lua/5.1/socket.lua:12: in main chunk
[C]: in function 'require'
stdin:1: in main chunk
[C]: ?
使用 require 'luarocks.loader'
也无济于事,同样的错误.我想无论如何我都不需要它,因为我已经使用 luarocks
路径设置了 LUA_PATH
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屋!