无法在 lua 中加载 lua 文件系统
can not load luafilesystem in lua
当我在 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) and package.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 文件中加载 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.