4

when i load lfs module in lua file, i got the error message:

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)'

here is the code:

#!/usr/bin/lua
package.path = package.path .. ";/usr/lib64/lua/5.1/?.so"
require"lfs"

if i execute the code in lua console, it succeed; if i copy the lfs.so file to the same directory as the lua file, i succeed too. i had googled,but can't find a solution.

4

1 回答 1

3

您正在加载一个 C 库。对于 C 库包,要使用的路径应该是package.cpath.

package.path(对于用 Lua 编写的模块)和package.cpath(对于用 C 编写的模块)是 Lua 查找模块的地方。它们是分号分隔的列表,每个条目都可以有一个?替换为模块名称的条目。

(资源)

于 2015-11-09T10:51:23.037 回答