I've added the lua source to my DLL project (removed lua.c and luac.c). I have the below code as a DLL project in VS and I'm getting a lua_createtable() linker error (lua_newtable() is a macro that calls lua_createtable()). What's odd is lua_createtabel() is defined in lapi.c which an .obj is getting generated so not really sure why I get the linker error.
#define DLL_EXPORT __declspec(dllexport)
#include "lua.h"
#include "lauxlib.h"
#include "lualib.h"
#define PI (3.14159265358979323846)
static int miles_to_km(lua_State *L)
{
double miles = luaL_checknumber(L, 1);
double km = miles * 1.609;
lua_pushnumber(L, km);
return 1; /* one result */
} /* end of miles_to_km */
static int circle_calcs(lua_State *L)
{
double radius = luaL_checknumber(L, 1);
double circumference = radius * 2 * PI;
double area = PI * radius * radius;
lua_pushnumber(L, circumference);
lua_pushnumber(L, area);
return 2; /* one result */
} /* end of miles_to_km */
static const luaL_Reg testlib[] =
{
{ "miles_to_km", miles_to_km },
{ "circle_calcs", circle_calcs },
{ NULL, NULL }
};
/*
** Open msg library
*/
DLL_EXPORT int luaopen_msglib(lua_State *L)
{
//luaL_openlib(L, "msg", msglib, 0);
lua_newtable(L);
//luaL_setfuncs(L, testlib, 0);
//lua_setglobal(L, "Test");
return 1;
}