当我在lua文件中加载lfs模块时,我收到错误消息:
error loading module 'lfs' from file '/usr/lib64/lua/5.1/lfs.so':
/usr/lib64/lua/5.1/lfs.so:1: unexpected symbol near 'char(127)'
这是代码:
#!/usr/bin/lua
package.path = package.path .. ";/usr/lib64/lua/5.1/?.so"
require"lfs"
如果我在lua控制台中执行代码,它就会成功; 如果我将 lfs.so 文件复制到与 lua 文件相同的目录,我也会成功。 我用谷歌搜索过,但找不到解决方案。
最佳答案
您正在加载 C 库。对于 C 库包,要使用的路径应为 package.cpath
。
package.path
(for modules written in Lua) andpackage.cpath
(for modules written in C) are the places where Lua looks for modules. They are semicolon-separated lists, and each entry can have a?
in it that's replaced with the module name.
关于lua - 无法在lua中加载lua文件系统,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33541581/