Lua在iPhone上? [英] Lua on the iPhone?
问题描述
我想在iPhone上使用Lua。在Mac OS X上,在普通(非iOS)Cocoa应用程序中,我使用了以下代码:
I am trying to use Lua on the iPhone. On Mac OS X, in a normal (non-iOS) Cocoa application, I used the following code:
lua_State* l;
l = lua_open();
luaL_openlibs(l);
luaL_loadstring(l, "print(\"Hi from Lua\");");
lua_pcall(l, 0, 0, 0);
我从lua.org/ftp下载了Lua 5.1.4并将其编译为Mac OS X.
在Xcode项目中,我使用添加现有框架添加 liblua.a
,并使用添加现有文件添加包含目录。
I downloaded Lua 5.1.4 from lua.org/ftp and compiled it for Mac OS X.
In the Xcode project, I used "Add Existing Framework" to add liblua.a
and I used "Add Existing Files" to add the include directory.
这按预期工作,并打印字符串:来自Lua。
当我在iOS项目中尝试相同的事情时,它会给出错误:
This works as expected, and prints the string: "Hi from Lua". When I try the same thing in an iOS project, it gives the errors:
"_luaL_newstate", referenced from:
_main in main.o
more of the same thing...
symbol(s) not found
collect2: ld returned 1 exit status
似乎.a文件未链接到iPhone应用程序。
有人知道如何使这项工作吗?
It seems that the .a file is not linked into the iPhone app. Does anybody know how to make this work?
(顺便说一下,如果它有Lua,我真的不在乎Apple可能不接受我的应用程序在它。)
(By the way, I don't really care that Apple might not accept my app if it has Lua in it.)
推荐答案
你需要为ARM编译Lua .a,而不是Intel。如果Lua库使用autoconf,您可以使用我最喜欢的iphone / autoconf构建器: build_for_iphoneos
。如果它不是autoconf,那么你可以使用该脚本来了解如何攻击它。有时您可以构建一个静态库Xcode项目,将所有文件转储到其中并点击构建。如果构建足够简单,它将为您完成大部分工作。
You'll need to compile the Lua .a for ARM, not Intel. If the Lua library uses autoconf, you can use my favorite iphone/autoconf builder: build_for_iphoneos
. If it's not autoconf, then you can use that script to get an idea of how to attack it. Sometimes you can just build a Static Library Xcode project, dump all the files into it and hit build. If the build is simple enough, it'll do most of the work for you.
我知道它对您的使用无关紧要,但基于Lua的工具是通常可以在应用程序商店发货。您无法在运行时下载任意代码并进行解释。
I know it doesn't matter for your use, but Lua-based tools are generally shippable on the app store. You just can't download arbitrary code at run time and interpret it.
这篇关于Lua在iPhone上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!