【问题标题】:sqlite3 extension-functions: The specified module could not be foundsqlite3 extension-functions:找不到指定的模块
【发布时间】:2018-09-10 22:09:34
【问题描述】:

我正在尝试加载 extension-functions sqlite3 扩展。 C文件可以在底部找到here

我正在运行 win10 并使用 VS2015。我已将 32 位和 64 位版本编译(没有错误)为 .dll,并尝试使用 sqlite3 shell 加载它们,但出现相同错误。 (分别使用 sqlite3.dll 文件的 32 位和 64 位版本)。下面我尝试使用 32 位 sqlite 加载扩展。

sqlite> select load_extension('C:\sqlite\ext32.dll');
Error: The specified procedure could not be found.
sqlite> select load_extension('C:\sqlite\ext64.dll');
Error: The specified module could not be found.

我使用这个命令来编译 32bit cl extension-functions.c -link -dll -out:ext32.dll。然后我运行 vcvarsall x64 并运行 cl extension-functions.c -link -dll -out:ext64.dll 以获得 64 位版本。

【问题讨论】:

  • 放弃扩展?而且由于您没有提供路径,因此请确保它位于您的 sqlite3 shell 的工作目录中。
  • 我想使用扩展给出的中值函数...我还更新了我的帖子以显示 64 位和 32 位之间的错误差异,并确保 dll 在路径中。
  • 文档指出“出于安全原因,加载的扩展程序默认关闭,必须通过事先调用 sqlite3_enable_load_extension() 来启用”。也就是说,您应该重新构建 sqlite3 程序以允许加载扩展。
  • Note that the command-line shell program has already enabled extension loading for you (by calling the sqlite3_enable_load_extension() interface as part of its setup) so the command above works without any special switches, setup, or other complications.

标签: dll sqlite


【解决方案1】:

extension-functions.c 不导出任何函数(又名“过程”),因此,输出 DLL 毫无用处。

SQLite shell 需要一个名为 sqlite3_extension_init 的函数,如Programming Loadable Extensions SQLite 文档一章所述。

因此,您只需像这样修改extension-functions.c(大约在第 1837 行)。

之前:

#ifdef COMPILE_SQLITE_EXTENSIONS_AS_LOADABLE_MODULE
int sqlite3_extension_init(
    sqlite3 *db, char **pzErrMsg, const sqlite3_api_routines *pApi){
  SQLITE_EXTENSION_INIT2(pApi);
  RegisterExtensionFunctions(db);
  return 0;
}
#endif /* COMPILE_SQLITE_EXTENSIONS_AS_LOADABLE_MODULE */

之后:

#ifdef COMPILE_SQLITE_EXTENSIONS_AS_LOADABLE_MODULE
#ifdef _WIN32
__declspec(dllexport)
#endif
int sqlite3_extension_init(
    sqlite3 *db, char **pzErrMsg, const sqlite3_api_routines *pApi){
  SQLITE_EXTENSION_INIT2(pApi);
  RegisterExtensionFunctions(db);
  return 0;
}
#endif /* COMPILE_SQLITE_EXTENSIONS_AS_LOADABLE_MODULE */

【讨论】:

  • 好的,这确实是使用cl 修复它,谢谢。我实际上是通过安装 mingw 并使用 gcc 编译来让它工作的。 gcc 正确导出函数,无需进行上述任何修改。 gcc 版本的运行速度也略快。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2020-08-12
  • 1970-01-01
  • 2016-04-27
  • 1970-01-01
  • 1970-01-01
  • 2017-09-17
  • 2011-01-05
相关资源
最近更新 更多