我正试图编译此C代码以获取dll:
#include<windows.h>
#include<lauxlib.h>
#include<lua.h>
/*************/
/* FUNCTIONS */
/*************/
/* helloluatex_greetings */
static int helloluatex_greetings(lua_State *L)
{
printf("Hello to LuaTeX from the world's smallest DLL!");
return 0;
}
/***************************/
/* Lua name to C functions */
/***************************/
static const luaL_Reg helloluatex[] = {{"greetings", helloluatex_greetings},
{NULL, NULL}};
/****************************/
/* MAIN DLL EXPORT FUNCTION */
/****************************/
LUA_API luaopen_helloluatex (lua_State *L)
{
luaL_register(L, "helloluatex", helloluatex);
return 1;
}
但我收到这个错误:
[linker error] undefined reference to 'luaL_register'
我在Windows Vista上使用Dev-C++4.9.9.2。
你看到我失败的地方了吗?
您必须将lua51.lib
链接到您的项目中,该项目包含lua_*
函数的定义。您可以通过进入项目->属性->链接器->输入并将lua51.lib
添加到库列表中,或者添加来完成此操作
#pragma comment(lib, "lua51.lib")
代码中的某个位置。