just few final considerations about dynamically loading mod_spatialite
1. mod_spatialite isn't an elementary simple object, it depends on
several other libraries that need to be loaded in turn.
the list includes PROJ, GEOS, RTTOPO (if Topology is enabled),
XML2, ICONV and CURL, just to cite the most relevant ones.
2. a failure in loading any one of them will cause a general
failure thus forbidding to load mod_spatialite itself.
3. last but not least, all these modules require to be
supported by some specific version of the C or C++
runtime. it strictly depends on the compiler make
and version used in order to build each module.
just to be more precise, all Windows DLLs distributed
by SpatiaLite itself are built using MinGW, a port
for Windows of the well known GCC compiler almost
universally adopted on Linux/Unix.
MinGW has a remarkably high compatibility with the
Microsoft native runtime implementations available
on Windows, but sometimes some ill-fated combinations
couldn't work, most easily when mixing at random
modules built in different years thus being based
on strongly different versions of runtime.
4. the final complexity touch: the search rules adopted
by Windows for dynamically loading external modules
are really chaotic.
and to make matters worst, the error messages returned
by this Operating System in the case of failure simply
is a meaningless "Unable to load" completely lacking
any other useful information about the real cause
forbidding the operation.
note that recent changes introduced by Win 8 and 10
have made this unpleasant situation even worst of
what it was on XP and 7.
short conclusions:
==================
A. dynamically loading mod_spatialite on Windows is quite
easy and simple if you are using all component of the
same age/version built by the same compiler.
this is the classic case of loading mod_spatialite
on the top of sqlite3.exe using the binaries shipped
into the SpatiaLite own distribution.
it's a stable and robust configuration, and is expected
to correctly work everywhere.
B. unhappily, this _IS NOT_ the case of loading mod_spatialite
on the top of Python, Java and so on.
all them are highly complex frameworks using their own
libraries and runtime support; many unexpected conflicts
and compatibility issues may easily arise.
C. the robust and safe solution to this problem is rather
obvious; you should always build a specific make of
mod_spatialite carefully checking to use the appropriate
compiler and libraries (possibly, the same used for
building the whole Python or Java stack).
this is not a task you can expect to be fulfilled by
SpatiaLite itself, because there are so many different
flavors and versions of these popular languages that
supporting all them would require an extraordinay effort
well beyond our practical possibilities.
however, it seems reasonable asking the maintainers of
your specific distro (as e.g. Anaconda) to directly
support their own version of mod_spatialite (as it
usually happens in the most popular Linux distros).
D. as practical experience in the field shows, a clever
hacking could actually solve many apparently desperate
situations.
unhappily such a solution surely requires a thorough
comprehension about the internal mechanisms of the
Operating System, which the average user usually lacks.
E. final hint.
learn to use the nice Depenndency Walker in order to
debug this kind of Windows issues.
it's the unique tool capable to shed some light on
such issues, and it's not to much complex to be used.
https://www.dependencywalker.com/
bye Sandro