Lua:加载模块文件时出错 [英] Lua: error loading module file not found

查看:183
本文介绍了Lua:加载模块文件时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试设置Lighttpd + lua + fastcgi以在嵌入式MIPS板上运行Web界面.但我想这里最重要的是Lua.尝试运行/usr/local/bin/wsapi.fcgi(这是lua脚本)时,出现此错误:

I'm trying to set up Lighttpd + lua + fastcgi to run web interface on an embedded MIPS board. But the important part here, I guess is Lua. When trying to run /usr/local/bin/wsapi.fcgi (which is lua script) I get this error:

/usr/bin/lua: error loading module 'lfcgi' from file '/usr/local/lib/lua/5.1/lfcgi.so':
    File not found
    stack traceback:
    [C]: ?
    [C]: in function 'require'
    /usr/local/share/lua/5.1/wsapi/fastcgi.lua:9: in main chunk
    [C]: in function 'require'
    /usr/local/bin/wsapi.fcgi:9: in main chunk
    [C]: ?

这真的很奇怪,因为ls显示文件在那里并且所有权限都正确:

Which is really strange, because ls shows that file is there and all permissions are ok:

# ls -l /usr/local/lib/lua/5.1/lfcgi.so
-rwxr-xr-x    1 0        0           21152 /usr/local/lib/lua/5.1/lfcgi.so

更令人沮丧的是,如果我实际上删除了文件,lua会显示一个不同的错误,这意味着第一个错误并不是由lua不能正确定位文件引起的.所以我在这里有点迷茫,看起来错误消息令人误解,问题实际上不是找不到文件,而是...

And which is more frustrating, if I actually remove the file, lua shows a different error, which means that first error wasn't really caused by lua unable to locate file properly. So I'm a bit lost here, looks like the error message is misleading and problem isn't really the file being not found, but what...

P.S.错误来自第9行的wsapi/fastcgi.lua文件,如下所示:

P.S. The error comes from file wsapi/fastcgi.lua, from line 9 which looks like this:

local lfcgi = require"lfcgi"

-可能require语法有问题吗?我不是lua的专家,所以我不知道.

- maybe there is something wrong with require syntax? I'm no expert in lua so I can't tell.

推荐答案

好,我知道了.正如@Ctx建议的那样,结果证明它是缺少的依赖项.

Ok, I figured it out. It turned out to be a missing dependency, as @Ctx suggested.

readelf -d lfcgi.so | grep NEEDED 

显示它需要 libfcgi.so.0 ,它是libfcgi.so的符号链接,我只有最后一个,而没有符号链接.创建符号链接后,它现在可以正常工作(实际上它还带有另一个错误,但这是一个不同的故事:P).

shows that it needs libfcgi.so.0 which is a symlink to libfcgi.so and I only have the last one, not the symlink. After creating the symlink it is working now (actually it comes with another error, but it is a different story :P).

顺便说一句-错误消息确实令人困惑-看起来文件lfcgi.so丢失了,而实际上它是导致问题的原因之一.

By the way - the error message is really confusing - it looks like the file lfcgi.so is missing, when in fact it is one of its dependencies that is causing the problem.

这篇关于Lua:加载模块文件时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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