SQLite Forum

Using sqlite3_load_extension on windows
Login
Can anyone tell me where I'm going wrong here? I'm using C++ bulder 10.2 (clang compiler). From IDE menu I've selected File|New|Dynamic Link Library and chosen compile as C with no dependencies. I've then added sqliteFcts.c and made the sqliteFcts.dll library. It all compiles fine.

Contents of sqliteFcts.c.
//-------------------------------------
#include <sqlite3ext.h>

SQLITE_EXTENSION_INIT1

#ifdef _WIN32
__declspec(dllexport)
#endif

int sqlite3_sqliteFcts_init(
  sqlite3 *db,
  char **pzErrMsg,
  const sqlite3_api_routines *pApi
){
  int rc = SQLITE_OK;
  SQLITE_EXTENSION_INIT2(pApi);

  return rc;
}

// SQLite code is above. Code below was created by the IDE
// Commenting out the code below still gives the same error message
#pragma argsused
int _libmain(unsigned long reason)
{
  return 1;
}
//------------------------------------

From my own app I try to use the dll with the following code

int rc;
sqlite3_db_config(db,SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION,1,&rc);
// sets rc=1
rc=sqlite3_load_extension(db,"C:/temp/sqliteFcts.dll",0,&buf);
// rc==1 and buf contains "The specified procedure cannot be found\r\n"