How do I specify a lib path for the SQLite FFI?

55 views
Skip to first unread message

David Storrs

unread,
Sep 11, 2018, 8:35:50 PM9/11/18
to Racket Users
Current version of SQLite is 3.24, but OSX (in my case 10.11, El Capitan) comes with sqlite3 version 3.8.10 installed.  

I've downloaded the new sqlite3 et al and put them in my path so I can use the new features.  Now I'd like to make Racket use the new code as well.  I cannot update the actual libsqlite3 files, or even add a new version alongside it in the standard /usr/lib/ location, because Apple decided that even root users are not smart enough to handle such things.

If I get a new version of libsqlite3 and put it in some per-user directory, how can I tell the Racket db module to link the SQLite code against this new library instead of the outdated default system one?

Matthew Flatt

unread,
Sep 11, 2018, 9:04:47 PM9/11/18
to David Storrs, Racket Users
At Tue, 11 Sep 2018 20:35:46 -0400, David Storrs wrote:
> If I get a new version of libsqlite3 and put it in some per-user directory,
> how can I tell the Racket db module to link the SQLite code against this
> new library instead of the outdated default system one?

The simplest approach is to put "libsqlite3.dylib" in Racket's "lib"
directory. Read further only if that's not good enough.


The parts of Racket that load foreign libraries generally go through
`ffi-lib`. There's a search path description in the docs for `ffi-lib`,
but it chains to several other things.

Mostly, the search path is based on `get-lib-search-dirs` from
`setup/dirs`. That search path can be configured though Racket's
"etc/config.rktd", but that's probably not what you want to change. The
first result from `get-lib-search-dirs` is a user-specific directory;
that's probably not what you want, either, but it's based on
`(find-system-path 'addon-dir)` and the Racket version number (or, more
precisely, the installation name).

Finally, the last step in the `ffi-lib` search is to let the OS perform
it's own search. If I remember correctly, Mac OS will search based on
the `DYLD_LIBRARY_PATH` environment variable.

David Storrs

unread,
Sep 12, 2018, 11:13:06 AM9/12/18
to Matthew Flatt, Racket Users
You are, as always, brilliant.  Thanks, Matt, that fixed it.

--
You received this message because you are subscribed to the Google Groups "Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages