在C应用程序中加载Lua库。
我想让我的 C 程序能够调用 Lua 函数,但我不知道如何加载 Lua 库。
目前我尝试从 lua.org 下载所有 Lua 源代码,然后将它们放在与我的 C 程序相同的文件夹中。然后在 C 代码中将它们包含进去。
现在我的代码如下所示:
#include "lua.h"
#include "lauxlib.h"
int main()
{
lua_State *L = luaL_newstate();
luaL_openlibs(L);
luaL_dofile(L, "test.lua");
return 0;
}
编译时出现的错误信息:
test.c: In function ‘main’: test.c:10:5: warning: implicit declaration of function ‘luaL_openlibs’ [->Wimplicit-function-declaration] luaL_openlibs(L); ^ In file included from test.c:5:0: lauxlib.h:122:24: warning: value computed is not used [-Wunused-value] (luaL_loadfile(L, fn) || lua_pcall(L, 0, LUA_MULTRET, 0)) ^ test.c:11:5: note: in expansion of macro ‘luaL_dofile’ luaL_dofile(L, "test.lua"); ^ /tmp/ccHJTAY8.o: In function
main': test.c:(.text+0x9): undefined reference toluaL_newstate' test.c:(.text+0x1e): undefined reference toluaL_openlibs' test.c:(.text+0x34): undefined reference toluaL_loadfilex' test.c:(.text+0x5f): undefined reference to `lua_pcallk' collect2: error: ld returned 1 exit status
- 如何将两个不同的lua文件合成一个 东西有点长 大佬请耐心看完 我是小白研究几天了都没搞定
- 如何在roblox studio中1:1导入真实世界的地形?
- 求解,lua_resume的第二次调用继续执行协程问题。
- 【上海普陀区】内向猫网络招募【Skynet游戏框架Lua后端程序员】
- SF爱好求教:如何用lua实现游戏内调用数据库函数实现账号密码注册?
- Lua实现网站后台开发
- LUA错误显式返回,社区常见的规约是怎么样的
- lua5.3下载库失败
- 请问如何实现文本框内容和某个网页搜索框内容连接,并把网页输出来的结果反馈到另外一个文本框上
- lua lanes多线程使用
- 一个kv数据库
- openresty 有没有比较轻量的 docker 镜像
- 想问一下,有大佬用过luacurl吗
- 在Lua执行过程中使用Load函数出现问题
- 为什么 neovim 里没有显示一些特殊字符?
- Lua比较两个表的值(不考虑键的顺序)
- 有个lua简单的项目,外包,有意者加微信 liuheng600456详谈,最好在成都
- 如何在 Visual Studio 2022 中运行 Lua 代码?
- addEventListener 返回 nil Lua
- Lua中获取用户配置主目录的跨平台方法