C++ and Lua with SQLite
C++ and Lua with SQLite
我有带有Lua绑定的c++。一切都很好,但是如果我添加SQLite,我的脚本停止工作(甚至没有一个空脚本只有一个print
运行)。
luaL_openlibs( this->state );
luaopen_lsqlite3(this->state); /* sqlite */
如果我这样做,Lua脚本不再工作。
如果我删除(注释掉)luaopen_lsqlite3
,脚本工作(但显然没有SQLite)。怎么了?或者我该怎么称呼?
我使用http://lua.sqlite.org/index.cgi/index
我找到了一个解决方案,这需要编辑Lua源文件。
In add
#define LUA_SQLLIBNAME "lsqlite3"
LUAMOD_API int (luaopen_lsqlite3)(lua_State *L);
之前LUALIB_API void (luaL_openlibs) (lua_State *L);
linit.h将{LUA_SQLLIBNAME, luaopen_lsqlite3 }
添加到loadedlibs
数组中。得到
static const luaL_Reg loadedlibs[] = {
{"_G", luaopen_base},
{LUA_LOADLIBNAME, luaopen_package},
{LUA_COLIBNAME, luaopen_coroutine},
{LUA_TABLIBNAME, luaopen_table},
{LUA_IOLIBNAME, luaopen_io},
{LUA_OSLIBNAME, luaopen_os},
{LUA_STRLIBNAME, luaopen_string},
{LUA_BITLIBNAME, luaopen_bit32},
{LUA_MATHLIBNAME, luaopen_math},
{LUA_DBLIBNAME, luaopen_debug},
{LUA_SQLLIBNAME, luaopen_lsqlite3 },
{NULL, NULL}
};
现在,如果你调用luaL_openlibs,在Lua中调用local sqlite3 = require("lsqlite3")
后,SQLite支持将在你的代码中出现
相关文章:
- 查询SQLite数据库中的日期
- 带内存和隔离功能的SQLite
- Problems with std::cin.fail()
- Qt SQLite没有查询或参数计数不匹配
- Qt SQlite无法创建表
- 应用程序崩溃并显示"symbol _ZdlPvm, version Qt_5 not defined in file libQt5Core.so.5 with link time reference"
- 这对"With a stackless coroutine, only the top-level routine may be suspended."意味着什么
- Boost.TEST with CLion: "Test framework quit unexpectedly"
- 避免碎片化的ClientHellos with OpenSSL (DTLS)
- Issues with Win32 ReadProcessMemory API
- Qt with WinAPI MouseProc
- 数数并选择 sqlite 中的前三名
- [[maybe_unused]] with structured_binding?
- Issue with WriteProcessMemory
- 如何使用SQLite将数据库中的值导出为C / C++中的字符串或字符?
- OpenCV RTP-Stream with FFMPEG
- "Unable to start debugging. No process is associated with this object." - 在Visual Studio Code中使用GDB
- std::adjacent_difference with std::chrono time_point
- Using SQLite with WinRT
- C++ and Lua with SQLite