Lua 编译

Lua编译器:luac.c

Lua解释器:lua.c

luac.clua.c 中各有一个 main 函数,生成时只能保留一个文件

生成dll文件不仅要在编译器中设置,同时需要定义 LUA_BUILD_AS_DLL

碰到 LUA_USE_WINDOWS 中编译无法通过的选项,

可以使用 "ISO C definition" 中的选项

如:

//缺少io.h头文件
#if !defined(lua_stdin_is_tty)    
    #if defined(LUA_USE_POSIX)    
        #include <unistd.h>
        #define lua_stdin_is_tty()    isatty(0)
    #elif defined(LUA_USE_WINDOWS)    
        #include <io.h> 
        #include <windows.h>
        #define lua_stdin_is_tty()    _isatty(_fileno(stdin))
    #else                
        /* ISO C definition */
        #define lua_stdin_is_tty()    1  
    #endif                
#endif    

//可以改为:
#if !defined(lua_stdin_is_tty)    
    #if defined(LUA_USE_POSIX)    
        #include <unistd.h>
        #define lua_stdin_is_tty()    isatty(0)
    #else                
        /* ISO C definition */
        #define lua_stdin_is_tty()    1  
    #endif                
#endif   
//_popen,_pclose函数未定义
#if !defined(l_popen)        
    #if defined(LUA_USE_POSIX)    
        #define l_popen(L,c,m)        (fflush(NULL), popen(c,m))
        #define l_pclose(L,file)    (pclose(file))
    #elif defined(LUA_USE_WINDOWS)    
        #define l_popen(L,c,m)        (_popen(c,m))
        #define l_pclose(L,file)    (_pclose(file))
    #else                
        /* ISO C definitions */
        #define l_popen(L,c,m)  \
              ((void)((void)c, m), \
              luaL_error(L, "'popen' not supported"), \
              (FILE*)0)
        #define l_pclose(L,file)    ((void)L, (void)file, -1)
    #endif                
#endif

//可改为
#if !defined(l_popen)        
    #if defined(LUA_USE_POSIX)    
        #define l_popen(L,c,m)        (fflush(NULL), popen(c,m))
        #define l_pclose(L,file)    (pclose(file))
    #else                
        /* ISO C definitions */
        #define l_popen(L,c,m)  \
              ((void)((void)c, m), \
              luaL_error(L, "'popen' not supported"), \
              (FILE*)0)
        #define l_pclose(L,file)    ((void)L, (void)file, -1)
    #endif                
#endif  

猜你喜欢

转载自blog.csdn.net/weixin_35338800/article/details/83149038