2
votes

I have this simple program which i make into dll in Visual C++ 2008 Express:

#include <lua52/lua.h>
#include <lua52/lualib.h>
#include <lua52/lauxlib.h>
#pragma comment(lib,"lua52.lib")
#include <stdio.h>

int needless(lua_State *L)
{
printf("bullshit\n");
return 0;
}
static const struct luaL_Reg noise[] = {
    {"needless",needless},
    {NULL,NULL}
};
__declspec(dllexport) int __cdecl luaopen_noise(lua_State *L)
{

luaL_newlib(L, noise);
    return 1;
}

when I link the resulting dll with "import noise" in lua5.2 interpreter, I get that "multiple lua VMs detected" for reason that eludes me. What should I do to fix make it work?

1
Don't you need an extern C around the block of Lua #includes since they are written in C? - Oliver
The code above 'is' C code so no externs needed. - kuniqs

1 Answers

1
votes

Lua libraries written in C should not include a copy of the Lua core library.

I don't know Visual C+ but this line is probably the culprit:

#pragma comment(lib,"lua52.lib")