Reputation: 61
My C code is below:
#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);
#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;
}
And lua code is below:
require "skypeAnalyzer"
skypeAnalyzer.run("Lua")
I compile dll in vs express 2013 and generate skypeAnalyzer.dll, but when I run lua code, there are the following error:
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'
How to dynamically call lua52.dll when compile the dll? How to set in VS 2013? I compile dll in vs express 2013 and generate skypeAnalyzer.dll, but when I run lua code, there are the following error:
Anyone can help me?
Upvotes: 3
Views: 360
Reputation: 81042
Your lua code is requiring itself.
Use a different name for the .dll
and .lua
files.
With lua 5.1 you would have gotten the slightly more useful error trace:
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]: ?
Upvotes: 2