in project, build lua5.1 library "lfs"(https://github.com/keplerproject/luafilesystem) adding lfs.c , lfs.h in makefile of lua, works well.
but after upgrading lua5.3, fails this:
$ lua test.lua lua: test.lua:1: module 'lfs' not found: no field package.preload['lfs'] no file '/usr/local/share/lua/5.3/lfs.lua' no file '/usr/local/share/lua/5.3/lfs/init.lua' no file '/usr/local/lib/lua/5.3/lfs.lua' no file '/usr/local/lib/lua/5.3/lfs/init.lua' no file './lfs.lua' no file './lfs/init.lua' no file '/usr/local/lib/lua/5.3/lfs.so' no file '/usr/local/lib/lua/5.3/loadall.so' no file './lfs.so' stack traceback: [c]: in function 'require' test.lua:1: in main chunk [c]: in ?
test.lua:
local lfs = require"lfs" function attrdir (path) file in lfs.dir(path) if file ~= "." , file ~= ".." local f = path..'/'..file print ("\t "..f) local attr = lfs.attributes (f) assert (type(attr) == "table") if attr.mode == "directory" attrdir (f) else name, value in pairs(attr) print (name, value) end end end end end attrdir(".")
i've checked latest "lfs" library lua5.3 supported.
my os macos 10.12, , here makefile i'm using
# makefile building lua # see ../doc/readme.html installation , customization instructions. # == change settings below suit environment ======================= # platform. see plats possible values. plat= none cc= gcc -std=gnu99 cflags= -o2 -wall -wextra -dlua_compat_5_2 $(syscflags) $(mycflags) ldflags= $(sysldflags) $(myldflags) libs= -lm $(syslibs) $(mylibs) ar= ar rcu ranlib= ranlib rm= rm -f syscflags= sysldflags= syslibs= mycflags= myldflags= mylibs= myobjs= # == end of user settings -- no need change below line ======= plats= aix bsd c89 freebsd generic linux macosx mingw posix solaris lua_a= liblua.a core_o= lapi.o lcode.o lctype.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o \ lmem.o lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o \ ltm.o lundump.o lvm.o lzio.o lib_o= lfs.o crc32.o lauxlib.o lbaselib.o lbitlib.o lcorolib.o ldblib.o liolib.o \ lmathlib.o loslib.o lstrlib.o ltablib.o lutf8lib.o loadlib.o linit.o base_o= $(core_o) $(lib_o) $(myobjs) lua_t= lua lua_o= lua.o luac_t= luac luac_o= luac.o all_o= $(base_o) $(lua_o) $(luac_o) all_t= $(lua_a) $(lua_t) $(luac_t) all_a= $(lua_a) # targets start here. default: $(plat) all: $(all_t) o: $(all_o) a: $(all_a) $(lua_a): $(base_o) $(ar) $@ $(base_o) $(ranlib) $@ $(lua_t): $(lua_o) $(lua_a) $(cc) -o $@ $(ldflags) $(lua_o) $(lua_a) $(libs) $(luac_t): $(luac_o) $(lua_a) $(cc) -o $@ $(ldflags) $(luac_o) $(lua_a) $(libs) clean: $(rm) $(all_t) $(all_o) depend: @$(cc) $(cflags) -mm l*.c echo: @echo "plat= $(plat)" @echo "cc= $(cc)" @echo "cflags= $(cflags)" @echo "ldflags= $(sysldflags)" @echo "libs= $(libs)" @echo "ar= $(ar)" @echo "ranlib= $(ranlib)" @echo "rm= $(rm)" # convenience targets popular platforms all= none: @echo "please 'make platform' platform 1 of these:" @echo " $(plats)" aix: $(make) $(all) cc="xlc" cflags="-o2 -dlua_use_posix -dlua_use_dlopen" syslibs="-ldl" sysldflags="-brtl -bexpall" bsd: $(make) $(all) syscflags="-dlua_use_posix -dlua_use_dlopen" syslibs="-wl,-e" c89: $(make) $(all) syscflags="-dlua_use_c89" cc="gcc -std=c89" @echo '' @echo '*** c89 not guarantee 64-bit integers lua.' @echo '' freebsd: $(make) $(all) syscflags="-dlua_use_linux" syslibs="-wl,-e -lreadline" generic: $(all) linux: $(make) $(all) syscflags="-dlua_use_linux" syslibs="-wl,-e -ldl -lreadline" macosx: $(make) $(all) syscflags="-dlua_use_macosx" syslibs="-lreadline" cc=cc mingw: $(make) "lua_a=lua53.dll" "lua_t=lua.exe" \ "ar=$(cc) -shared -o" "ranlib=strip --strip-unneeded" \ "syscflags=-dlua_build_as_dll" "syslibs=" "sysldflags=-s" lua.exe $(make) "luac_t=luac.exe" luac.exe posix: $(make) $(all) syscflags="-dlua_use_posix" solaris: $(make) $(all) syscflags="-dlua_use_posix -dlua_use_dlopen -d_reentrant" syslibs="-ldl" # list targets not create files (but not makes understand .phony) .phony: $(plats) default o clean depend echo none # not delete lapi.o: lapi.c lprefix.h lua.h luaconf.h lapi.h llimits.h lstate.h \ lobject.h ltm.h lzio.h lmem.h ldebug.h ldo.h lfunc.h lgc.h lstring.h \ ltable.h lundump.h lvm.h lauxlib.o: lauxlib.c lprefix.h lua.h luaconf.h lauxlib.h lbaselib.o: lbaselib.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h lbitlib.o: lbitlib.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h lcode.o: lcode.c lprefix.h lua.h luaconf.h lcode.h llex.h lobject.h \ llimits.h lzio.h lmem.h lopcodes.h lparser.h ldebug.h lstate.h ltm.h \ ldo.h lgc.h lstring.h ltable.h lvm.h lcorolib.o: lcorolib.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h lctype.o: lctype.c lprefix.h lctype.h lua.h luaconf.h llimits.h ldblib.o: ldblib.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h ldebug.o: ldebug.c lprefix.h lua.h luaconf.h lapi.h llimits.h lstate.h \ lobject.h ltm.h lzio.h lmem.h lcode.h llex.h lopcodes.h lparser.h \ ldebug.h ldo.h lfunc.h lstring.h lgc.h ltable.h lvm.h ldo.o: ldo.c lprefix.h lua.h luaconf.h lapi.h llimits.h lstate.h \ lobject.h ltm.h lzio.h lmem.h ldebug.h ldo.h lfunc.h lgc.h lopcodes.h \ lparser.h lstring.h ltable.h lundump.h lvm.h ldump.o: ldump.c lprefix.h lua.h luaconf.h lobject.h llimits.h lstate.h \ ltm.h lzio.h lmem.h lundump.h lfunc.o: lfunc.c lprefix.h lua.h luaconf.h lfunc.h lobject.h llimits.h \ lgc.h lstate.h ltm.h lzio.h lmem.h lgc.o: lgc.c lprefix.h lua.h luaconf.h ldebug.h lstate.h lobject.h \ llimits.h ltm.h lzio.h lmem.h ldo.h lfunc.h lgc.h lstring.h ltable.h linit.o: linit.c lprefix.h lua.h luaconf.h lualib.h lauxlib.h liolib.o: liolib.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h llex.o: llex.c lprefix.h lua.h luaconf.h lctype.h llimits.h ldebug.h \ lstate.h lobject.h ltm.h lzio.h lmem.h ldo.h lgc.h llex.h lparser.h \ lstring.h ltable.h lmathlib.o: lmathlib.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h lmem.o: lmem.c lprefix.h lua.h luaconf.h ldebug.h lstate.h lobject.h \ llimits.h ltm.h lzio.h lmem.h ldo.h lgc.h loadlib.o: loadlib.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h lobject.o: lobject.c lprefix.h lua.h luaconf.h lctype.h llimits.h \ ldebug.h lstate.h lobject.h ltm.h lzio.h lmem.h ldo.h lstring.h lgc.h \ lvm.h lopcodes.o: lopcodes.c lprefix.h lopcodes.h llimits.h lua.h luaconf.h loslib.o: loslib.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h lparser.o: lparser.c lprefix.h lua.h luaconf.h lcode.h llex.h lobject.h \ llimits.h lzio.h lmem.h lopcodes.h lparser.h ldebug.h lstate.h ltm.h \ ldo.h lfunc.h lstring.h lgc.h ltable.h lstate.o: lstate.c lprefix.h lua.h luaconf.h lapi.h llimits.h lstate.h \ lobject.h ltm.h lzio.h lmem.h ldebug.h ldo.h lfunc.h lgc.h llex.h \ lstring.h ltable.h lstring.o: lstring.c lprefix.h lua.h luaconf.h ldebug.h lstate.h \ lobject.h llimits.h ltm.h lzio.h lmem.h ldo.h lstring.h lgc.h lstrlib.o: lstrlib.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h ltable.o: ltable.c lprefix.h lua.h luaconf.h ldebug.h lstate.h lobject.h \ llimits.h ltm.h lzio.h lmem.h ldo.h lgc.h lstring.h ltable.h lvm.h ltablib.o: ltablib.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h ltm.o: ltm.c lprefix.h lua.h luaconf.h ldebug.h lstate.h lobject.h \ llimits.h ltm.h lzio.h lmem.h ldo.h lstring.h lgc.h ltable.h lvm.h lua.o: lua.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h luac.o: luac.c lprefix.h lua.h luaconf.h lauxlib.h lobject.h llimits.h \ lstate.h ltm.h lzio.h lmem.h lundump.h ldebug.h lopcodes.h lundump.o: lundump.c lprefix.h lua.h luaconf.h ldebug.h lstate.h \ lobject.h llimits.h ltm.h lzio.h lmem.h ldo.h lfunc.h lstring.h lgc.h \ lundump.h lutf8lib.o: lutf8lib.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h lvm.o: lvm.c lprefix.h lua.h luaconf.h ldebug.h lstate.h lobject.h \ llimits.h ltm.h lzio.h lmem.h ldo.h lfunc.h lgc.h lopcodes.h lstring.h \ ltable.h lvm.h lzio.o: lzio.c lprefix.h lua.h luaconf.h llimits.h lmem.h lstate.h \ lobject.h ltm.h lzio.h lfs.o: lfs.c lfs.h crc32.o: crc32.c crc32.h # (end of makefile)
any advice appreciated
this have done , works well:
linit.c
added lfs in section:
static const lual_reg loadedlibs[] = { {"_g", luaopen_base}, ... {lua_lfslibname, luaopen_lfs},
and in lualib.h added
#define lua_lfslibname "lfs" luamod_api int (luaopen_lfs) (lua_state *l);
then build usual. hope helps.
Comments
Post a Comment