我正在尝试加载extension-functions
sqlite3扩展。 C文件可以在底部找到here。
我正在运行win10并使用VS2015。我已经编译(没有错误)32位和64位版本到.dll并尝试使用sqlite3 shell加载它们具有相同的错误。 (分别使用32位和64位版本的sqlite3.dll文件)。下面我试图使用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
并为64位版本运行cl extension-functions.c -link -dll -out:ext64.dll
。
extension-functions.c
不会导出任何函数(也称为'procedure'),因此,输出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 */