SQLite Forum

How to make a compiled SQLite extensions available system-wide on MacOS?
Login

How to make a compiled SQLite extensions available system-wide on MacOS?

(1) By anonymous on 2020-05-19 13:12:23 [source]

After I compile an extension from "ext/misc", where should I put it to make it callable from any directory while using ".load xxx" with SQLite CLI?

(2) By Larry Brasfield (LarryBrasfield) on 2020-05-20 00:40:22 in reply to 1 [link] [source]

If you provide an absolute path in the .load command or to the sqlite3_load_extension() call, or to the load_extension() SQLite function from SQL (when extension loading is enabled), then the extension specified by that path will be loaded (if it can be.)

If you want to name the extension to one of the load mechanisms without an absolute path, then you must arrange that the compiled extension can be located by the search that dlopen(...) conducts. That can vary, but usually it examines directories specified by an environment variable, LD_LIBRARY_PATH, in the order listed by its colon-separated values left-to-right, then /lib and /usr/lib.

So, you can put your extension somewhere already searched, or you could use the "env" command to launch the SQLite CLI with a modified value for $LD_LIBRARY_PATH that includes where you put the extension. Or you might simply modify that environment variable for a session in which you are using the CLI. (This can lead to subtle problems, so be sure you understand the potential effects going into that.)