为什么Lua报告lua_pushlstring未定义?
我成功地为 Palm webOS 编译了 Lua 5.1.4,现在我正在尝试编写一个扩展来使用 Lua 中的 webOS 服务。然而,当我尝试加载我的库时,Lua 报告:
undefined symbol: lua_pushlstring
这是我的代码:
#define LUA_LIB
#include "lua.h"
#include "lauxlib.h"
static int hellopalm(lua_State *L) {
lua_pushliteral(L, "Hello, Palm!");
return 1;
}
static const luaL_reg palmlib[] = {
{ "hellopalm", hellopalm },
{ NULL, NULL }
};
LUALIB_API int luaopen_palm(lua_State *L) {
luaL_register(L, "palm", palmlib);
return 1;
}
这是我的 Makefile:
LUADIR= ../lua-5.1.4/lua-webos
CC= arm-none-linux-gnueabi-gcc
CFLAGS= -O2 -Wall -shared -nostdlib -mcpu=arm1136jf-s -mfpu=vfp -mfloat-abi=softfp
INCLUDES= -I$(LUADIR)/include
RM= rm -f
LIBNAME= palmlib.so
SOURCES= palmlib.c
default: $(LIBNAME)
clean:
$(RM) $(LIBNAME)
$(LIBNAME): palmlib.c
$(CC) $(CFLAGS) $(INCLUDES) $(SOURCES) -o $@
我知道 lua_pushliteral
只是一个调用 lua_pushlstring
的宏,所以这就是错误来自。所有 push_*
变体似乎都不起作用。我怀疑我的 Makefile 有问题。
有什么想法吗?
I managed to compile Lua 5.1.4 for Palm webOS and now I'm trying to write an extension to use webOS' services from Lua. However, when I try to load my library, Lua reports:
undefined symbol: lua_pushlstring
Here's my code:
#define LUA_LIB
#include "lua.h"
#include "lauxlib.h"
static int hellopalm(lua_State *L) {
lua_pushliteral(L, "Hello, Palm!");
return 1;
}
static const luaL_reg palmlib[] = {
{ "hellopalm", hellopalm },
{ NULL, NULL }
};
LUALIB_API int luaopen_palm(lua_State *L) {
luaL_register(L, "palm", palmlib);
return 1;
}
Here's my Makefile:
LUADIR= ../lua-5.1.4/lua-webos
CC= arm-none-linux-gnueabi-gcc
CFLAGS= -O2 -Wall -shared -nostdlib -mcpu=arm1136jf-s -mfpu=vfp -mfloat-abi=softfp
INCLUDES= -I$(LUADIR)/include
RM= rm -f
LIBNAME= palmlib.so
SOURCES= palmlib.c
default: $(LIBNAME)
clean:
$(RM) $(LIBNAME)
$(LIBNAME): palmlib.c
$(CC) $(CFLAGS) $(INCLUDES) $(SOURCES) -o $@
I know lua_pushliteral
is just a macro that calls lua_pushlstring
, so that's where the error is coming from. None of the push_*
variants seem to work at all. I suspect something is wrong with my Makefile.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当你构建Lua解释器时,你需要导出Lua API符号。在 Linux 中,gcc 的标志是 -Wl、-E;也许这也适用于您的平台。
You need to export the Lua API symbols when you build your Lua interpreter. In Linux, the flags for gcc are -Wl,-E; perhaps this works in your platform as well.