我下载了this 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"
任何帮助将不胜感激!
答案 0 :(得分:4)
我看到了这些选项:
尝试make install
并希望它有效。也许设置一些变量,例如PREFIX
没有。
手动将dist/usr/local/share/lua/5.1/nixio
移至/usr/local/share/lua/5.1/nixio
,将dist/usr/local/lib/lua/5.1/nixio.so
移至/usr/local/lib/lua/5.1/nixio.so
。
将dist
路径添加到环境中:LUA_CPATH='dist/usr/local/lib/lua/5.1/?.so;;'
和LUA_PATH='dist/usr/local/share/lua/5.1/?.lua;;'
。
在Lua中添加dist
路径:package.cpath='dist/usr/local/lib/lua/5.1/?.so;'..package.cpath
和package.path='dist/usr/local/share/lua/5.1/?.lua;'..package.path
。