c - lua5.2在windows中调用c dll

标签 c windows dll lua lua-api

我的 C 代码如下:

skype分析器.h

#include "lua.h" 
#include "lualib.h" 
#include "lauxlib.h"
#include "stdio.h"
#include "stdlib.h"

//dll export func
int _declspec(dllexport) luaopen_skypeAnalyzer(lua_State* L);

skype分析器.c

#include "skypeAnalyzer.h"
#include <windows.h> 
#include <wincrypt.h> 

int run(lua_State* L){
    printf("------->>> Hi! %s \n", lua_tostring(L, 1));
    return 0;
}


struct luaL_Reg IrLibs[] = {

    { "run", run },
    { NULL, NULL }
};


int luaopen_skypeAnalyzer(lua_State* L)
{
    luaL_newlib(L, IrLibs);
    return 1;
}

lua代码如下:

require "skypeAnalyzer"
skypeAnalyzer.run("Lua")

我在vs express 2013中编译dll生成skypeAnalyzer.dll,但是运行lua代码时出现如下错误:

C:\Lua>lua52.exe skypeAnalyzer.lua
lua52.exe: C stack overflow
stack traceback:
        [C]: in ?
        [C]: in function 'require'
        C:\Lua\skypeAnalyzer.lua:1: in main chunk
        [C]: in function 'require'
        
       

如何在编译dll时动态调用lua52.dll?如何在 VS 2013 中设置?我在vs express 2013中编译dll生成skypeAnalyzer.dll,但是运行lua代码时出现如下错误:

谁能帮帮我?

最佳答案

你的 lua 代码需要它自己。

.dll.lua 文件使用不同的名称。

使用 lua 5.1 你会得到稍微有用的错误跟踪:

lua5.1: ./foo.lua:1: loop or previous error loading module 'foo'
stack traceback:
        [C]: in function 'require'
        ./foo.lua:1: in main chunk
        [C]: ?
        [C]: ?

关于c - lua5.2在windows中调用c dll,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27727853/

相关文章:

导入库可以同时包含 stub 和静态代码吗?

c - LinkedList函数在c中崩溃

c - 为变量分配了多少内存?

c - 如何在 C 中对多维字符数组使用 scanf()

python - 使用python在windows中获取ppid

c++ - 如何在 C++ 中获取进程的起始地址/基地址?

windows - 批处理文件 - 使用 ping 测试网络连通性

c++ - 为什么 Visual Studio 2015 不链接到依赖的 dll 项目

c++ - 控制台程序完成后转换到命令提示符?

c++ - 在 VB6 中,我是否需要在使用 SysAllocString 分配的字符串上调用 SysFreeString?