Skip to content Skip to sidebar Skip to footer

Libsqlite3.so Loading On Python

I want to replace libsqlite3 with the special version for Python. I have a special version of libsqlite3.so.0 /path/to/libsqlite3.so.0 and configured LD_LIBRARY_PATH. However, pyth

Solution 1:

You might try to force loading of the lib with:

LD_PRELOAD=/path/to/libsqlite3.so.0 python ...

The library will be loaded in memory when python will be executed. So normally when _sqlite3 module will be imported, it will not load libsqlite3.so.0, and use the version already preloaded in memory.

Edit

The LD_LIBRARY_PATH doesn't work in that case cause libsqlite3.so.0 is loaded by _sqlite.so module, loaded by dlopen() within Python. In that case, the manpage of dlopen() said that the order is:

  1. (ELF only) If the executable file for the calling program contains a DT_RPATH tag, and does not contain a DT_RUNPATH tag, then the directories listed in the DT_RPATH tag are searched.

  2. If, at the time that the program was started, the environment variable LD_LIBRARY_PATH was defined to contain a colon-separated list of directories, then these are searched. (As a security measure this variable is ignored for set-user-ID and set-group-ID programs.)

  3. ...

So if an DT_RPATH is set on the binary, it will be taken prior to your LD_LIBRARY_PATH.

Post a Comment for "Libsqlite3.so Loading On Python"