Undefined symbol : sqlite_extension_init

42 views
Skip to first unread message

Antoine Etc

unread,
Jun 8, 2022, 9:58:14 AMJun 8
to SpatiaLite Users
Hi, i'm trying to load Spatialite extension in JAVA application with 
        stmt.execute("SELECT load_extension('mod_spatialite.so')");

Then the error occurs :
[SQLITE_ERROR] SQL error or missing database (*PATH_TO_LIBDIR*/mod_spatialite.so: undefined symbol: sqlite3_extension_init).

I compiled spatialite with these following configure options :
--disable-rttopo --disable-minizip
I tried to load mod_spatialite, but application doesn't find mod_spatialite.

What can i do to solve the problem ?

Antoine Etc

unread,
Jun 8, 2022, 10:41:44 AMJun 8
to SpatiaLite Users
Here are dependencies versions :
  • geos : 3.9.2 
  • freexl : 1.0.5
  • spatialite : 5.0.1
  • proj : 8.2.1
  • zlib : 1.2.12

a.fu...@lqt.it

unread,
Jun 8, 2022, 11:06:05 AMJun 8
to spatiali...@googlegroups.com
On Wed, 8 Jun 2022 06:58:13 -0700 (PDT), Antoine Etc wrote:
> Hi, i'm trying to load Spatialite extension in JAVA application with
> STMT.EXECUTE("SELECT LOAD_EXTENSION('MOD_SPATIALITE.SO')");
>
> Then the error occurs :
> [SQLITE_ERROR] SQL ERROR OR MISSING DATABASE
> (*PATH_TO_LIBDIR*/MOD_SPATIALITE.SO: UNDEFINED SYMBOL:
> SQLITE3_EXTENSION_INIT).
>
> I compiled spatialite with these following configure options :
> --DISABLE-RTTOPO --DISABLE-MINIZIP
> I tried to load mod_spatialite, but application doesn't find
> mod_spatialite.
>
> What can i do to solve the problem ?
>

Hi Antoine,

you are missing to specify the unique relevant infos:

a) on wich OS/version are you working ?
I guess some kind of Linux (.so), but it's too vague

b) are you using directly sqlite3 for loading mod_spatialite
or some other tool (e.g. python, Java ...)

c) the most releavant question: wich version of SQLite3 ?

---------------------------------------

just some insight:

sqlite3_extension_init() was the expected entry point to be
declared by all extension modules many (many) years ago.

in modern times the convention for the entry point name
has changed, and consequently now mod_spatialite declares
as its entry point:

sqlite3_modspatialite_init()

I strongly suspect that your loading app complaints about
a missing sqlite3_extension_init() just because it's
some venerable fossil of longly gone eras and is still
unaware of the new convention about entry point names.

hint:
the load_extension() function has two different signatures,
one of them allowing to explictitly pass the name of the
entry point of the extension.

please check if the following call fixes your issue:

SELECT load_extension('mod_spatialite', 'sqlite3_modspatialite_init');

bye Sandro

Antoine Etc

unread,
Jun 9, 2022, 5:54:00 AMJun 9
to SpatiaLite Users
Hi Sandro,

Thank you for your answer and your responsiveness. 

Here are some infos :

with command lsb_release -a :
LSB Version:    :core-4.1-amd64:core-4.1-noarch
Distributor ID:    RedHatEnterpriseWorkstation
Description:    Red Hat Enterprise Linux Workstation release 7.5 (Maipo)
Release:    7.5
Codename:    Maipo

There is the initialization part of my JAVA code :
------------------------
      String URL_SQLITE = "jdbc:sqlite:" + DATABASE_PATH + DATABASE_NAME;
      File DatabaseSQLite = new File(DATABASE_PATH + DATABASE_NAME);
      if (DatabaseSQLite.exists()) {
        System.out.println("SQLite database " + DATABASE_NAME + " already exists at :\n\t" + DATABASE_PATH);
        System.out.println("Removing it.");
        if (DatabaseSQLite.delete()) System.out.println("Database deleted successfully");
      }

      SQLiteConfig configSQLite = new SQLiteConfig();
      configSQLite.enableLoadExtension(true);
      Properties prop = configSQLite.toProperties();

      Connection conn = DriverManager.getConnection(URL_SQLITE, prop);
      conn.setAutoCommit(false);
     
      Statement statement = conn.createStatement();
      statement.execute("SELECT load_extension('*Path to lib*/mod_spatialite.so',  'sqlite3_modspatialite_init');");
     
      System.out.println("Loaded");
--------------------------

So, to answer your question, (and if i understand what i am doing) i use JAVA code to manipulate sqlite3 (JDBC Driver 3.7.2 sqlite-jdbc).

Spatialite was compiled with sqlite3 version 3.38 lib. I didn't find what version of sqlite3 uses JDBC driver.

Thank you for your explanations. 

Your command fixed my issue, thanks !

Now I have SEGILL Error, which is far more frightening. I'll try things on my own, maybe i'll start another post later.

Bye

Antoine



a.fu...@lqt.it

unread,
Jun 9, 2022, 6:19:09 AMJun 9
to spatiali...@googlegroups.com
On Thu, 9 Jun 2022 02:54:00 -0700 (PDT), Antoine Etc wrote:
> So, to answer your question, (and if i understand what i am doing) i
> use JAVA code to manipulate sqlite3 (JDBC Driver 3.7.2 sqlite-jdbc).
>
> Spatialite was compiled with sqlite3 version 3.38 lib. I didn't find
> what version of sqlite3 uses JDBC driver.
>

Hi Antoine,

you are using a desperately outdated SQLite3 version:

I see that the JDBC Driver 3.7.2 sqlite-jdbc was released on
2010-08-27,
and it seems to be based on SQLite3 3.7.2 released on 2010-08-24
... about 12 years ago !!!

but you've built mod_spatialite using the current version 3.38;
I'm not al all surprised if you are experiencing some fatal crash,
because it's pretty sure that there a severe incompatibilities
between two versions of SQLite3 so distant in time.

I warmly suggest you to update your JDBC connector: a fairly
recent version seems to be:

https://github.com/xerial/sqlite-jdbc/releases/download/3.36.0.3/sqlite-jdbc-3.36.0.3.jar

bye Sandro
Reply all
Reply to author
Forward
0 new messages