iPhone 上的 Lua? [英] Lua on the iPhone?

查看:27
本文介绍了iPhone 上的 Lua?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 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项目中,我使用Add Existing Framework"添加liblua.a,并使用Add Existing Files"添加包含目录.

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.

这按预期工作,并打印字符串:Hi from 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 而不是 Intel 编译 Lua .a.如果 Lua 库使用 autoconf,你可以使用我最喜欢的 iphone/autoconf builder: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.

这篇关于iPhone 上的 Lua?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆