美文网首页
Unity——编译tolua

Unity——编译tolua

作者: 战斗力五只鹅 | 来源:发表于2020-05-26 19:49 被阅读0次

    参照这两篇教程编译tolua
    https://zhuanlan.zhihu.com/p/81935911
    https://github.com/NewbieGameCoder/tolua_runtime/wiki

    从mingw的shell执行build_xx.sh时报错。

    $ /h/Lua/tolua_runtime-1.0.8.584/build_win64.sh
    /h/Lua/tolua_runtime-1.0.8.584/build_win64.sh: 第 5 行:cd: luajit-2.1: No such file or directory
    mingw32-make: *** No rule to make target 'clean'.  Stop.
    mingw32-make: *** No targets specified and no makefile found.  Stop.
    cp: 无法获取"src/libluajit.a" 的文件状态(stat): No such file or directory
    mingw32-make: *** No rule to make target 'clean'.  Stop.
    gcc.exe: error: tolua.c: No such file or directory
    gcc.exe: error: int64.c: No such file or directory
    gcc.exe: error: uint64.c: No such file or directory
    gcc.exe: error: pb.c: No such file or directory
    gcc.exe: error: lpeg.c: No such file or directory
    gcc.exe: error: struct.c: No such file or directory
    gcc.exe: error: cjson/strbuf.c: No such file or directory
    gcc.exe: error: cjson/lua_cjson.c: No such file or directory
    gcc.exe: error: cjson/fpconv.c: No such file or directory
    gcc.exe: error: luasocket/auxiliar.c: No such file or directory
    gcc.exe: error: luasocket/buffer.c: No such file or directory
    gcc.exe: error: luasocket/except.c: No such file or directory
    gcc.exe: error: luasocket/inet.c: No such file or directory
    gcc.exe: error: luasocket/io.c: No such file or directory
    gcc.exe: error: luasocket/luasocket.c: No such file or directory
    gcc.exe: error: luasocket/mime.c: No such file or directory
    gcc.exe: error: luasocket/options.c: No such file or directory
    gcc.exe: error: luasocket/select.c: No such file or directory
    gcc.exe: error: luasocket/tcp.c: No such file or directory
    gcc.exe: error: luasocket/timeout.c: No such file or directory
    gcc.exe: error: luasocket/udp.c: No such file or directory
    gcc.exe: error: luasocket/wsocket.c: No such file or directory
    gcc.exe: error: window/x86_64/libluajit.a: No such file or directory
    
    

    这个是因为mingw找不到tolua相关的路径,不知道是教程少写了步骤,还是我对教程的理解有误,反正最后自己瞎捣鼓出来了。

    解决方法:

    1. 先打开cmd,cd到mingw安装路径
    -- cmd:
    > cd xxx/msys64
    
    1. cmd启动mingw的shell,以64位为例
    -- cmd:
    > mingw64_shell.bat
    
    1. mingw的shell里cd到tolua源码路径
    -- shell:
    $ cd x:/xxx/tolua_runtime-1.0.8.584
    
    1. mingw的shell里执行对应平台的build,这里注意shell里执行文件时和cmd里的命令不一样,需要文件前加上"./"
    -- shell:
    $ ./build_win64.sh
    

    编译成功,生成的dll在 tolua源码路径/Plugins/对应平台/ 下。

    $ ./build_win64.sh
    H:/Lua/msys64/mingw64/bin/mingw32-make -C src clean
    mingw32-make[1]: Entering directory 'H:/Lua/tolua_runtime-1.0.8.584/luajit-2.1/src'
    rm -f luajit.exe libluajit.a lua51.dll host/minilua.exe host/buildvm.exe lj_vm.S lj_bcdef.h lj_ffdef.h lj_libdef.h lj_recdef.h lj_folddef.h host/buildvm_arch.h jit/vmdef                                                                              .lua *.o host/*.o *.obj *.lib *.exp *.dll *.exe *.manifest *.pdb *.ilk
    mingw32-make[1]: Leaving directory 'H:/Lua/tolua_runtime-1.0.8.584/luajit-2.1/src'
    ==== Building LuaJIT 2.1.0-beta3 ====
    H:/Lua/msys64/mingw64/bin/mingw32-make -C src
    mingw32-make[1]: Entering directory 'H:/Lua/tolua_runtime-1.0.8.584/luajit-2.1/src'
    HOSTCC    host/minilua.o
    HOSTLINK  host/minilua.exe
    DYNASM    host/buildvm_arch.h
    HOSTCC    host/buildvm.o
    HOSTCC    host/buildvm_asm.o
    HOSTCC    host/buildvm_peobj.o
    HOSTCC    host/buildvm_lib.o
    HOSTCC    host/buildvm_fold.o
    HOSTLINK  host/buildvm.exe
    BUILDVM   lj_vm.o
    CC        lj_gc.o
    BUILDVM   lj_ffdef.h
    CC        lj_err.o
    CC        lj_char.o
    BUILDVM   lj_bcdef.h
    CC        lj_bc.o
    CC        lj_obj.o
    CC        lj_buf.o
    CC        lj_str.o
    CC        lj_tab.o
    CC        lj_func.o
    CC        lj_udata.o
    CC        lj_meta.o
    CC        lj_debug.o
    CC        lj_state.o
    CC        lj_dispatch.o
    CC        lj_vmevent.o
    CC        lj_vmmath.o
    CC        lj_strscan.o
    CC        lj_strfmt.o
    CC        lj_strfmt_num.o
    CC        lj_api.o
    CC        lj_profile.o
    CC        lj_lex.o
    CC        lj_parse.o
    CC        lj_bcread.o
    CC        lj_bcwrite.o
    CC        lj_load.o
    CC        lj_ir.o
    CC        lj_opt_mem.o
    BUILDVM   lj_folddef.h
    CC        lj_opt_fold.o
    CC        lj_opt_narrow.o
    CC        lj_opt_dce.o
    CC        lj_opt_loop.o
    CC        lj_opt_split.o
    CC        lj_opt_sink.o
    CC        lj_mcode.o
    CC        lj_snap.o
    CC        lj_record.o
    CC        lj_crecord.o
    BUILDVM   lj_recdef.h
    CC        lj_ffrecord.o
    CC        lj_asm.o
    CC        lj_trace.o
    CC        lj_gdbjit.o
    CC        lj_ctype.o
    CC        lj_cdata.o
    CC        lj_cconv.o
    CC        lj_ccall.o
    CC        lj_ccallback.o
    CC        lj_carith.o
    CC        lj_clib.o
    CC        lj_cparse.o
    CC        lj_lib.o
    CC        lj_alloc.o
    lj_alloc.c:176:14: warning: 'DIRECT_MMAP' defined but not used [-Wunused-function]
     static void *DIRECT_MMAP(size_t size)
                  ^
    CC        lib_aux.o
    BUILDVM   lj_libdef.h
    CC        lib_base.o
    CC        lib_math.o
    CC        lib_bit.o
    CC        lib_string.o
    CC        lib_table.o
    CC        lib_io.o
    CC        lib_os.o
    CC        lib_package.o
    CC        lib_debug.o
    CC        lib_jit.o
    CC        lib_ffi.o
    CC        lib_init.o
    AR        libluajit.a
    CC        luajit.o
    BUILDVM   jit/vmdef.lua
    LINK      luajit.exe
    OK        Successfully built LuaJIT
    mingw32-make[1]: Leaving directory 'H:/Lua/tolua_runtime-1.0.8.584/luajit-2.1/src'
    ==== Successfully built LuaJIT 2.1.0-beta3 ====
    H:/Lua/msys64/mingw64/bin/mingw32-make -C src clean
    mingw32-make[1]: Entering directory 'H:/Lua/tolua_runtime-1.0.8.584/luajit-2.1/src'
    rm -f luajit.exe libluajit.a lua51.dll host/minilua.exe host/buildvm.exe lj_vm.S lj_bcdef.h lj_ffdef.h lj_libdef.h lj_recdef.h lj_folddef.h host/buildvm_arch.h jit/vmdef.lua *.o host/*.o                                                              *.obj *.lib *.exp *.dll *.exe *.manifest *.pdb *.ilk
    mingw32-make[1]: Leaving directory 'H:/Lua/tolua_runtime-1.0.8.584/luajit-2.1/src'
    
    编译成功

    相关文章

      网友评论

          本文标题:Unity——编译tolua

          本文链接:https://www.haomeiwen.com/subject/imnvahtx.html