sqlite3扩展功能:找不到指定的模块

时间:2018-09-10 22:09:34

标签: dll sqlite

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

我正在运行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.

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

1 个答案:

答案 0 :(得分:1)

extension-functions.c不会导出任何功能(也称为“过程”),因此,输出DLL几乎没有用。

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

因此,您只需要像这样修改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 */