The specified module could not be found

581 views
Skip to first unread message

Saeed

unread,
Sep 1, 2017, 8:44:41 AM9/1/17
to SpatiaLite Users

Hi everybody

 

I am new in programming, and I want to use SpatiaLite library.

 

I have been using Postgre/postGIS for a long time; however, I recently decided to switch to SpatiaLite.  I download 'mod_spatialite' libraries package. It contains some dll files, and I put all dlls near my database file, and it was perfectly worked; however, I want to use SpatiaLite library for some reasons. There are so many dll packages which make me confused. I accidentally download one SpatiaLite library package. It contains some dlls, and I put all dlls near my database file. When I use “'SELECT load_extension('libspatialite-2.dll')'” code, I am facing “The specified module could not be found” error. And I do not know the reason.

 

Hope some could help me in this question.

 

Thanks in advance

 

a.fu...@lqt.it

unread,
Sep 1, 2017, 11:46:12 AM9/1/17
to spatiali...@googlegroups.com
On Fri, 1 Sep 2017 05:44:40 -0700 (PDT), Saeed wrote:
> Hi everybody
>
>  
>
> I am new in programming, and I want to use SpatiaLite library.
>
>  
>
> I have been using Postgre/postGIS for a long time; however, I
> recently
> decided to switch to SpatiaLite.  I download 'mod_spatialite'
> libraries package. It contains some dll files, and I put all dlls
> near
> my database file, and it was perfectly worked;
>

Hi Saeed,

placing the DDLs in the same directory where the database is may
casually work sometimes, but does not necessarily matches the
standard searching rules adopted by Windows:
1. DLLs are searched first in the same directory from where the
calling executable (*.exe) has been loaded.
2. if the previous step fails then the DLLs are searched in
system directories such as C:\Windows\System32
3. if not yet found then the DLLs are searched in the
current directory
4. a final attempt to locate the DLLs will be done by
searching all the directories listed in the PATH
environment variable.

the simpler and safer option usually is the one to place
all depending DLLs into the same directory where is
installed the calling application (*.exe).

note: a 32 bit application can only load 32 bit DLLs,
exactly as 64 bit apps strictly require 64 bit DLLs.
any attempt to mix 32 and 64 bit binary code is always
strictly forbidden, and will usually end up in an
error message "The specified module could not be found".


> however, I want to use SpatiaLite library for some reasons.
>

which reasons ?
could you explain better this specific point ?

recent versions of SpatiaLite come in two different
flavors, mod_spatialite and libspatialite.
both are exactly the same, and simply differ in
the expected way to be loaded and activated:
- mod_spatialite is specifically intended to be
loaded by executing a "SELECT load_extension()"
SQL statement.
- libspatialite is specifically intended to be
statically or dynamically linked into a C/C++
application (*.exe)
- you can never load libspatialite via the
"SELECT load_extension()" call exactly as
you can never link mod_spatialite to a C/C++
application; they are mutually exclusive.

please read this Wiki page for more details:
https://www.gaia-gis.it/fossil/libspatialite/wiki?name=mod_spatialite


> There are so many dll packages which make me confused.
>

there is just one "dll package" for each version of
SpatiaLite, and it's the universal "mod_spatialite".
"libspatialite" could just interest C/C++ developers
and isn't part of the standard binary distribution
for Windows (it was supported in very archaic versions,
but it's now unsupported).

at the current state of the art you can choose
between the following Windows packages:

http://www.gaia-gis.it/gaia-sins/windows-bin-x86/mod_spatialite-4.3.0a-win-x86.7z
Windows 32 bit mod_spatialite version 4.3.0a
a little bit obsolete but still usable

http://www.gaia-gis.it/gaia-sins/windows-bin-amd64/mod_spatialite-4.3.0a-win-amd64.7z
same as the above one but 64 bit

http://www.gaia-gis.it/gaia-sins/windows-bin-x86-test/mod_spatialite-4.4.0-RC0-win-x86.7z
Windows 32 bit mod_spatialite version 4.4.0-RCO
the most recent: warmly recommended

http://www.gaia-gis.it/gaia-sins/windows-bin-amd64-test/mod_spatialite-4.4.0-RC0-win-amd64.7z
same as the above one but 64 bit

Never ever try to use anything older than the
above ones; any previous version (including
4.2.0) should be now considered obsolete and
deprecated.

bye Sandro

Saeed Behzadi

unread,
Sep 1, 2017, 11:39:56 PM9/1/17
to spatiali...@googlegroups.com
Hi sandro

I really appreciate your valuable comments. Honesty, it takes me at
least one month to found these useful information.

About the reason of using ‘libspatialite’:
I am writing some GIS code to be used simultaneously in python,
matlab, scilab, and android. I used 'mod_spatialite' for python, which
worked correctly. In addition, I found matlab sqlite package named
“mksqlite” to connect to sqlite database:
https://sourceforge.net/projects/mksqlite/

Although I exactly did the same thing that I have done with python,
‘mksqlite’ package does not work with 'mod_spatialite' library, I end
up with “The specified module could not be found” error. I do not know
the reason. I found in ‘mksqlite’ help that ‘libspatialite-2.dll’ must
be used; as a result I tried to use “libspatialite”, which I failed
both in matlab and python. I am using python 3.6 32bit in win7(64bit).

As you kindly suggested downloading the last version, I download the
following link:
http://www.gaia-gis.it/gaia-sins/libspatialite-4.3.0a.zip; however, I
could not find libspatialite.dll in this package, while in package in
following link:
https://www.gaia-gis.it/spatialite-3.0.0-BETA/binaries.html, there was
this dll.

Saeed
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "SpatiaLite Users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/spatialite-users/B72kUcy8pLI/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> spatialite-use...@googlegroups.com.
> To post to this group, send email to spatiali...@googlegroups.com.
> Visit this group at https://groups.google.com/group/spatialite-users.
> For more options, visit https://groups.google.com/d/optout.
>

a.fu...@lqt.it

unread,
Sep 2, 2017, 4:02:58 AM9/2/17
to spatiali...@googlegroups.com
On Sat, 2 Sep 2017 08:09:53 +0430, Saeed Behzadi wrote:
> About the reason of using ‘libspatialite’:
> I am writing some GIS code to be used simultaneously in python,
> matlab, scilab, and android. I used 'mod_spatialite' for python,
> which
> worked correctly. In addition, I found matlab sqlite package named
> “mksqlite” to connect to sqlite database:
> https://sourceforge.net/projects/mksqlite/
>

Hi Saeed,

at least in theory 'mod_spatialite' should work with every possible
language and/or tool (C/C++, C#, Python, Java, PHP, Lisp and many
others).

it just depends on the dynamic extensions loading mechanism
internally implemented by libsqlite3 that is expected to be the
same on all platforms and for all embedding languages.

there are few specific factors we must take in proper account
that sometimes can badly forbid this elegant "universal" schema:
we'll see later all them in more detail.


> Although I exactly did the same thing that I have done with python,
> ‘mksqlite’ package does not work with 'mod_spatialite' library, I end
> up with “The specified module could not be found” error. I do not
> know
> the reason.
>

as I said before, the dynamic extension loading mechanism is
directly implemented by libsqlite3, but different versions of
this library can work in different ways because this interface
evolved during the years.

more specifically, there was a critical change introduced by sqlite
3.7.17; 'mod_spatialite' strictly requires the most recent version
of the dynamic extension loading interface, and consequently can't
never work with any sqlite version released before 3.7.17

note: version 3.7.17 was released on May 2013 (four years ago), so
it's absolutely reasonable assuming that any modern package/language
should support a decently fresh version of sqlite.
but sometimes it happens that poorly managed packages still continue
to distribute unbelievably archaic versions of sqlite; and I have
the impression that matlab is one of them.

hint: carefully check which version of libsqlite3 is actually
called by python, matlab etc.


> I found in ‘mksqlite’ help that ‘libspatialite-2.dll’ must
> be used; as a result I tried to use “libspatialite”, which I failed
> both in matlab and python. I am using python 3.6 32bit in
> win7(64bit).
>

absolutely no: libspatialite-2.dll is nowadays obsolete and
deprecated, and shouldn't never be used for new installations.
if 'mksqlite' still continues to require libspatialite instead
of mod_spatialite it's clearly their fault: you could try asking
the maintainers to support up-to-date versions.


> As you kindly suggested downloading the last version, I download the
> following link:
> http://www.gaia-gis.it/gaia-sins/libspatialite-4.3.0a.zip; however, I
> could not find libspatialite.dll in this package
>

there is no libspatialite.dll simply because it's completely
useless when using recent versions of libsqlite.
mod_spatialite is all that is needed.


> while in package in following link:
> https://www.gaia-gis.it/spatialite-3.0.0-BETA/binaries.html, there
> was
> this dll.
>

surely yes, but it's an obsolete and deprecated version [released
on August 2011, six years ago].
you can try using it at your own risk, but you can't expect any
help or assistance.

bye Sandro
Reply all
Reply to author
Forward
0 new messages