Il 2026-02-02 11:47
ckgoo...@gmail.com ha scritto:
> I have a proj.dll and its proj.db in my executable folder.
>
Hello Chris,
Note: the effects of the absence (or presence of an
inconsistent version) of proj.dll and proj.db are very
different and easily distinguishable:
a) a missing or mismatching proj.dll causes a load error;
the extension module cannot be loaded and the call to
load_extension() fails.
b) a missing or mismatched proj.db will instead cause
runtime problems.
The extension module will load correctly, but the
first call to ST_Transform() will give incorrect
results.
> ... including spatialite.dll (which I rename to
> mod_spatialite.dll"
>
This is definitely wrong.
libspatialite and mod_spatialite are two completely
different objects and you can't interchange them.
- libspatialite is a classic dynamic library, and is
specifically designed to be linked directly into an
executable developed in C or C++
- mod_spatialite on the other hand is not a library at
all, it's a dynamically loaded module made specifically
to be loaded by SQLite's load_extension().
> With this I get an error of "Error during initialisation"
> ... the default entry point has been changed
>
This is the obvious result of the above; your fake mod_spatialite
doesn't have the expected entry point at all, precisely because
it's just a poorly disguised libspatialite.
Given your context, I think the simplest solution for you is to
change the way you load SpatiaLite.
Since you don't have a real mod_spatialite, forget about using
SQLite's load_extension().
To initialize libspatialite in the classic C/C++ way, you can
take some inspiration from the followind code snippet:
-------------------------------------------------------
Start - Initialing
-------------------------------------------------------
sqlite3 * sqlite;
const char *path;
int mode;
void *cache;
int ret;
// opening the DB connection
ret = sqlite3_open_v2(path, &sqlite, mode, NULL);
if (ret)
; // do some error handling
// properly setting SQLite
ret = sqlite3_exec (sqlite,
"PRAGMA trusted_schema=0",
NULL, NULL, NULL);
if (ret != SQLITE_OK)
; // do some error handling
ret = sqlite3_exec (sqlite,
"PRAGMA foreign_keys=1",
NULL, NULL, NULL);
if (ret != SQLITE_OK)
; // do some error handling
// initialing SpatiaLite
cache = spatialite_alloc_connection();
spatialite_init_ex(sqlite, cache, 0);
// properly initialize the SpatiaLite DB
ret = sqlite3_exec (sqlite,
"SELECT InitSpatialMetadataFull()",
NULL, NULL, NULL);
if (ret != SQLITE_OK)
; // do some error handling
-------------------------------------------------------
End - Closing and freeing resources
-------------------------------------------------------
sqlite3_close(sqlite);
spatialite_shutdown();
spatialite_cleanup_ex(cache);
-------------------------------------------------------
best regards.
Samdrp