开发者

Why does Lua report that lua_pushlstring is undefined?

开发者 https://www.devze.com 2023-01-05 01:02 出处:网络
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:

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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号