sqlite3 extension-functions: The specified module could not be found

别来无恙 提交于 2021-02-08 05:29:44

问题


I'm trying to get the extension-functions sqlite3 extension to load. The C file can be found here at the bottom.

I'm running win10 and using VS2015. I have compiled (with no errors) both 32 and 64 bit versions to .dll and tried loading them using the sqlite3 shell with the same error. (Using both 32 and 64 bit versions of the sqlite3.dll file respectively). Below I'm trying to load the extension using 32bit 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.

I used this command for compiling 32bit cl extension-functions.c -link -dll -out:ext32.dll. Then I ran vcvarsall x64 and ran cl extension-functions.c -link -dll -out:ext64.dll for the 64bit version.


回答1:


extension-functions.c doesn't export any function (aka 'procedure'), so, as is, the output DLL is pretty useless.

The SQLite shell expects a function named sqlite3_extension_init as stated in the Programming Loadable Extensions SQLite documentation chapter.

So, you just have to modify extension-functions.c like this (around line 1837).

Before:

#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 */

after:

#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 */


来源:https://stackoverflow.com/questions/52266158/sqlite3-extension-functions-the-specified-module-could-not-be-found

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!