1. (Under Linux)cannot find ‘dlsym’ ‘dlopen’ ‘dlerror’ ‘dlclose’


  2. (Under Linux)编译lua报错luaconf.h:275:31: error: readline/readline.h: No such file or directory

    需要下载并安装GNU Readline Library

  3. PANIC: unprotected error in call to Lua API (unable to get ModuleFileName)

    1: 不推荐的解决方式:将Project Properties->Configuration Properties->General下的Character Set从unicode改成multi-set;
    2: 彻底的解决方式,参考此链接:

  4. 如何将Lua文本文件转化为Lua块文件(chunk file)

    调用LuaAPI – lua_dump

    关于lua_dump: about lua_dump: Dumps a function as a binary chunk. Receives a Lua function on the top of the stack and produces a binary chunk that, if loaded again, results in a function equivalent to the one dumped. As it produces parts of the chunk, lua_dump calls function writer (see lua_Writer) with the given data to write them.

  5. 如何在C中调用Lua脚本层的库函数

    void BeginLuaLibCall( lua_State *L, const string &libName, const string &functionName )
         lua_pushstring( L, libName.c_str() );
         lua_gettable( L, LUA_GLOBALSINDEX );
         lua_pushstring( L, functionName.c_str() );
         lua_gettable( L, -2 );
    void EndLuaLibCall( lua_State *L )
         lua_pop( L, -1 );


    // 利用上面的函数
    BeginLuaLibCall( L, "table", "getn" );
    // 假设你的脚本中有一个table变量myTable,获取它到栈顶
    lua_getglobal( L, "myTable" ); 
    // 执行table.getn( t )
    lua_call( L, 1, 1 ); 
    // 打印结果
    std::cout << lua_tonumber( L, -1 ) ) << std::endl;
    // 将结果弹出栈
    lua_pop( L, -1 );
    // 将名叫“table”的table弹出栈
    EndLuaLibCall( L);
This entry was written by Benny Chen , posted on Monday November 08 2010at 12:11 pm , filed under Lua, 游戏开发 | Game Programming and tagged , , , . Bookmark the permalink . Post a comment below or leave a trackback: Trackback URL.

2 Responses to “Lua相关问题整理(1)”

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>