【发布时间】:2015-12-06 02:32:56
【问题描述】:
我正在尝试使用 C++ 执行 Lua 文件。
我正在运行 Mac OS X 并且 Lua 5.3 位于 /usr/local/include
当我尝试执行 Lua 文件时,出现以下错误:
Undefined symbols for architecture x86_64:
"lua_settop(lua_State*, int)", referenced from:
_main in lual-8d0dcd.o
"luaopen_base(lua_State*)", referenced from:
main::lualibs in lual-8d0dcd.o
"luaL_newstate()", referenced from:
_main in lual-8d0dcd.o
"lua_close(lua_State*)", referenced from:
_main in lual-8d0dcd.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
这是 C++ 文件:
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>
int main(int argc, char* argv[]) {
lua_State *lua_state;
lua_state = luaL_newstate();
static const luaL_Reg lualibs[] = {
{ "base", luaopen_base },
{ NULL, NULL}
};
const luaL_Reg *lib = lualibs;
for(; lib->func != NULL; lib++) {
lib->func(lua_state);
lua_settop(lua_state, 0);
}
luaL_dofile(lua_state, "helloworld.lua");
lua_close(lua_state);
return 0;
}
谁能帮帮我?
谢谢。
【问题讨论】: