Unity——編譯tolua

參照這兩篇教程編譯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'
編譯成功
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。