我想连接luabridge库,该库允许您将lua脚本连接到c ++,但是什么也没发生,出现错误,我什至不知道如何修复
代码:
#include <LuaBridge.h>
#include <iostream>
#include <string>
extern "C" {
# include "lua.h"
# include "lauxlib.h"
# include "lualib.h"
}
using namespace luabridge;
int main() {
lua_State* L = luaL_newstate();
luaL_dofile(L, "script.lua");
luaL_openlibs(L);
lua_pcall(L, 0, 0, 0);
LuaRef s = getGlobal(L, "testString");
LuaRef n = getGlobal(L, "number");
std::string luaString = s.cast<std::string>();
int answer = n.cast<int>();
std::cout << luaString << std::endl;
std::cout << "And here's our number:" << answer << std::endl;
}
正如错误所报告的,指令的
#include
顺序错误正确顺序的示例可以在 LuaBridge 使用示例中看到(例如,此处)