嵌入lua运行时错误:符号未找到:_luaL_newstate
embed lua runtime error: Symbol not found: _luaL_newstate
我的代码
inline int DOFILE(string& filename) {
printf("lua_openn");
/* initialize Lua */
lua_State* L = lua_open();
printf("lua_openlibsn");
/* load Lua base libraries */
luaL_openlibs(L);
printf("lua_dofilen");
/* run the script */
int ret = luaL_dofile(L, filename.c_str());
printf("lua_closen");
/* cleanup Lua */
lua_close(L);
return ret;
}
编译选项:
obj.cxxflags = ["-g", "-D_FILE_OFFSET_BITS=64", "-D_LARGEFILE_SOURCE", "-Wall", "-llua-5.1"]
也尝试了'-llua', '-llualib',它们都报告警告
i686-apple-darwin11-llvm-g++-4.2: -llua-5.1: linker input file unused because linking not done
当我运行时,它报告:
lua_open
dyld: lazy symbol binding failed: Symbol not found: _luaL_newstate
Referenced from: /Users/gl/workspace/node-lua/build/Release/node_lua.node
Expected in: flat namespace
dyld: Symbol not found: _luaL_newstate
Referenced from: /Users/gl/workspace/node-lua/build/Release/node_lua.node
Expected in: flat namespace
您应该为库使用obj.ldflags
参数。
您正在使用的构建工具分两步生成二进制文件:
- 链接
编译步骤使用obj.cxxflags
编译器标志。库不需要编译,所以传递链接器标志(-lfoo
)是没有用的——编译器根本不使用它们(因此有警告)。
链接步骤应同时使用obj.cxxflags
和obj.ldflags
。(ld
是链接器的名称)
g++ -o thing thing.cpp -lpthread
。但是对于较大的构建,通常将编译和链接分开。)
相关文章:
- 没有找到相关文章