Yes.

Simply append the extension to the sqlite3.c source code.  When you do this you 
need to have the symbol SQLITE_CORE defined so that the extension calls the 
sqlite3* entrypoints directly rather than through the indirection table.  The 
main sqlite3.c source should take care of this for you. (But if you compile the 
extension into a separate linkage unit, you need to define SQLITE_CORE 
manually).

Then you need to write an "extra init" function to add the extension 
entry-points to the auto-extension list at sqlite3 init time.  There is a 
symbol which causes this function to be called at sqlite3 init time called 
SQLITE_EXTRA_INIT (go look in the source).  You define this to be your "extra 
init" function that uses sqlite3_auto_init to add all the extension init 
routines to be initialized on each connection.  Append this to sqlite3.c 
*after* the extensions.  (Or compile into a separate linkage unit with 
SQLITE_CORE defined).

Then compile sqlite3.c as you normally would but with SQLITE_EXTRA_INIT defined 
to your extra init function.  (and, if not inline, add the extra linkage units 
to the link-edit step)  The added extensions will now be available to every 
connection.

You may have to make some changes to some of the extension code you do this 
with if it has extra symbols, duplicate symbols, or (for example on Windows) 
tries to export the init function since you no longer need to export that 
symbol.

---
The fact that there's a Highway to Hell but only a Stairway to Heaven says a 
lot about anticipated traffic volume.

>-----Original Message-----
>From: sqlite-users [mailto:sqlite-users-
>boun...@mailinglists.sqlite.org] On Behalf Of Thomas Kurz
>Sent: Thursday, 26 April, 2018 06:06
>To: SQLite mailing list
>Subject: [sqlite] copmile SQLite with extension?
>
>I have a project with heavily uses the libsqlitefunctions extension.
>It is a bit annoying to "select load_extension('...')" for every
>connection.
>
>Is it possible to compile an sqlite.dll which already has the
>extension embedded so that the functions provided can be used without
>further initialization required?
>
>_______________________________________________
>sqlite-users mailing list
>sqlite-users@mailinglists.sqlite.org
>http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users



_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to