2

当我在终端中运行我的代码时,

local function main()
    local socket = require ("socket.http")
 end
main()

我收到此错误/消息:找不到模块“socket.http”:

 no field package.preload['socket.http']
 no file '/usr/local/share/lua/5.2/socket/http.lua' 
 no file '/usr/local/share/lua/5.2/socket/http/init.lua' 
 no file '/usr/local/lib/lua/5.2/socket/http.lua' 
 no file '/usr/local/lib/lua/5.2/socket/http/init.lua' 
 no file './socket/http.lua' 
 no file '/usr/local/lib/lua/5.2/socket/http.so' 
 no file '/usr/local/lib/lua/5.2/loadall.so' 
 no file './socket/http.so' 
 no file '/usr/local/lib/lua/5.2/socket.so' 
 no file '/usr/local/lib/lua/5.2/loadall.so' 
 no file './socket.so'

我在 Windows 中使用 lua,但我不知道如何实现它。我想使用 LuaSocket 从 http 存储库中获取图像,然后对其进行 base64 编码,而无需下载图像。这与文件系统中的图像一起使用,此解决方案有效:

 dofile("C:\\Users\\se47596\\Desktop\\LUA\\prueba2\\src\\Base64.lua")
 imagen = "C:\\Users\\se47596\\Desktop\\LUA\\prueba2\\src\\pruebaAsyncOCR.png"
 local function main()
   imfh = io.open(imagen,'rb')
   imblob = imfh:read('*a')
   imfh:close()
   print("ImageData="..enc(imblob))
 end
 main()

我应该将哪些文件导入到我的 Eclipse 项目中?我看到了这些操作,但我不知道如何使用它们......

  --package.path = "./lua/modules/?.lua"
  --package.cpath = "./lua/modules/?.dll"
  --local socket = require ("socket")

我应该如何构建我的项目?至少我有这个:

我的项目文件夹

 |__src
   |__Base64.lua
   |__main.lua

请问你能帮帮我吗?我想用 Lua 解释器来证明它。我也看到了这些解决方案,但我无法让它在我的 Eclipse 项目中工作,也许我需要上一步。我需要创建一个库吗?在那种情况下我怎么能这样做?

http://w3.impa.br/~diego/software/luasocket/installation.html http://luarocks.org/

此致!

4

2 回答 2

3

First error looks like you are running in Linux??

Have you successfully installed LuaSockets? Its written in C so you need a compiler to install it. That can be found in Microsoft developer tools. You can also use cygwin.

Alternatively if you have mingw installed you can first download: https://github.com/pkulchenko/ZeroBraneStudio/blob/master/build/build-win32.sh

Then you can run:

bash ./build-win32.sh lua luasocket
于 2013-06-18T22:12:33.793 回答
0

我可以顺便构建它们:

(1) 像这样替换 build-win32.sh 中的 gcc/g++:

 GCC=x86_64-w64-mingw32-gcc
 GPP=x86_64-w64-mingw32-g++
 #gcc $BUILD_FLAGS
 $GCC $BUILD_FLAGS

(2) apt-cyg cmake 解压 mingw64-x86_64-gcc-g++

(3) bash ./build-win32.sh lua luasocket

于 2018-12-14T02:48:28.887 回答