2

我下载了这个Lua 模块并用 make 安装了它。但是,当我尝试在我的代码中使用它时,出现以下错误:

VirtualBox:~/Downloads$ lua socket_test.lua 
lua: socket_test.lua:1: module 'nixio.util' not found:
    no field package.preload['nixio.util']
    no file './nixio/util.lua'
    no file '/usr/local/share/lua/5.1/nixio/util.lua'
    no file '/usr/local/share/lua/5.1/nixio/util/init.lua'
    no file '/usr/local/lib/lua/5.1/nixio/util.lua'
    no file '/usr/local/lib/lua/5.1/nixio/util/init.lua'
    no file '/usr/share/lua/5.1/nixio/util.lua'
    no file '/usr/share/lua/5.1/nixio/util/init.lua'
    no file './nixio/util.so'
    no file '/usr/local/lib/lua/5.1/nixio/util.so'
    no file '/usr/lib/i386-linux-gnu/lua/5.1/nixio/util.so'
    no file '/usr/lib/lua/5.1/nixio/util.so'
    no file '/usr/local/lib/lua/5.1/loadall.so'
    no file './nixio.so'
    no file '/usr/local/lib/lua/5.1/nixio.so'
    no file '/usr/lib/i386-linux-gnu/lua/5.1/nixio.so'
    no file '/usr/lib/lua/5.1/nixio.so'
    no file '/usr/local/lib/lua/5.1/loadall.so'
stack traceback:
    [C]: in function 'require'
    socket_test.lua:1: in main chunk
    [C]: ?

我的代码的第一行:

local nixio = require "nixio", require "nixio.util"

任何帮助,将不胜感激!

4

1 回答 1

4

我看到这些选项:

  1. 尝试make install并希望它有效。也许设置一些变量,例如PREFIX什么都没有。

  2. 手动移动dist/usr/local/share/lua/5.1/nixio/usr/local/share/lua/5.1/nixiodist/usr/local/lib/lua/5.1/nixio.so/usr/local/lib/lua/5.1/nixio.so

  3. dist路径添加到环境:LUA_CPATH='dist/usr/local/lib/lua/5.1/?.so;;'LUA_PATH='dist/usr/local/share/lua/5.1/?.lua;;'.

  4. 在Lua dist:package.cpath='dist/usr/local/lib/lua/5.1/?.so;'..package.cpathpackage.path='dist/usr/local/share/lua/5.1/?.lua;'..package.path.

于 2013-11-14T18:36:31.650 回答