在参考:https://github.com/probablycorey/wax 搭建的过程中,运行官方的例子,console中总是出现:
Error opening wax scripts: loading wax stdlib: bad header in precompiled chunk
经过漫长的查找,最终发现是我的开发机的Lua版本不对,应该这样:
首先,官方文档没提需要在开发机上安装Lua,这个是必须安装的,因为编译脚本需要Lua支持。
Lua在这里下载:http://www.lua.org/download.html
编辑 lua-5.1.4/src/Makefile,将:
macosx: $(MAKE) all MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-lreadline"
改为:
macosx: $(MAKE) all MYCFLAGS="-DLUA_USE_LINUX -arch i386" MYLIBS="-lreadline -arch i386"
最后:
$ make macosx
$ sudo make install
让我发现这个问题,是因为在wax/lib/build-scripts/copy-scripts.sh中,有这样的注释:
# This requires that you run a special build of lua. Since snow leopard is 64-bit
# and iOS is 32-bit, luac files compiled on snow leopard won't work on iOS
另外注意,由于需要重写wax/lib/stdlib/wax_stdlib.h文件,所以要注意此文件是否有写权限,另外在编译时,加上compile-stdlib.sh脚本,以重新编译wax_stdlib.h。
在xcode4下安装wax的教程,以及对应的中文版:
http://mobile.tutsplus.com/tutorials/iphone/iphone-wax/
http://mobile.51cto.com/hot-269986_1.htm
另外,需要注意的是,如果执行安装模板的脚本(虽然在xcode4下装不上,我也提一下),需要在zsh下运行。