9

I have compiled SQLite3 3.8.6 and installed it to ${HOME}/opt with:

LDFLAGS="-L${HOME}/opt/lib" CFLAGS="-L${HOME}/opt/include" ./configure --prefix=$HOME/opt
make && make install

I am now trying to compile Python 3.4.2 to use this version instead of the version installed for the entire system. I do not have root access on this system. To compile Python, I am using:

LDFLAGS="-L${HOME}/opt/lib" CFLAGS="-L${HOME}/opt/include" ./configure --prefix=$HOME/opt
make && make install

I was able to compile Python 3.3.5 with my newer version if SQLite3, but these same steps don't seem to work for me for 3.4.2.

How can I compile Python 3.4.2 to include my version of SQLite 3.8.6 which is located in ${HOME}/opt?

Thanks.

EDIT: It compiles & installs OK except for the fact that is using the older, system version of sqlite3 instead of the version that I compiled & installed myself.

Colonel Thirty Two
  • 23,953
  • 8
  • 45
  • 85
jftuga
  • 1,913
  • 5
  • 26
  • 49
  • Try to get some output during the install to see all that it is doing and it is not pointing to a wrong place – jgr208 Oct 08 '14 at 15:59
  • Are you sure it uses the system version and not its own copy? – CL. Oct 09 '14 at 06:34
  • @CL: Yes. I did a `find . | grep sqlite3.h` inside the Python-3.4.2 source directory and it did not return any files. – jftuga Oct 09 '14 at 13:09
  • This same issue has me baffled too. There is no system libsqlite3-dev package installed, only the runtime; I've built and installed sqlite3 3.8.8 in /usr/local, configured and built Python 3.4.2 which still reports '3.7.9' as the `sqlite3.sqlite_version`. – tzot Jan 20 '15 at 11:54

3 Answers3

15

There is also the option of pre-linking your custom Python build with your own-built sqlite3. (I had the same issue: the custom python was using the system-provided sqlite3, completely ignoring the sqlite3 I built).

Prefix your configure and make commands with:

LD_RUN_PATH=$HOME/opt/lib configure LDFLAGS="-L$HOME/opt/lib" CPPFLAGS="-I$HOME/opt/include" …
LD_RUN_PATH=$HOME/opt/lib make

so that the built python3 by default is linked to your sqlite3. This worked for me.

tzot
  • 92,761
  • 29
  • 141
  • 204
  • Thanks, this works perfectly. Now, there is no need to use the LD_LIBRARY_PATH in my .bashrc. – jftuga Jan 30 '15 at 18:50
  • 1
    As an alternative, adding `-Wl,-rpath=$HOME/opt/lib` (a linker flag that tells `ld` to write `$HOME/opt/lib` into the runtime path of any binaries it makes) to `LDFLAGS` will (robustly and permanently) accomplish the same thing, at least if your compiler is GCC. Sources: [here](http://linuxmafia.com/faq/Admin/ld-lib-path.html) and [here](http://xahlee.info/UnixResource_dir/_/ldpath.html). – TheDudeAbides Sep 26 '19 at 19:53
1
import platform,sqlite3
print("Oper Sys : %s %s" % (platform.system(), platform.release()))
print("Platform : %s %s" % (platform.python_implementation(),platform.python_version()))
print("SQLite   : %s" % (sqlite3.sqlite_version))

When I run this code, the output contains the system's version of sqlite3:

Oper Sys : Linux 3.2.0-4-amd64
Platform : CPython 3.4.2
SQLite   : 3.7.13

After installing sqlite v3.8.6 under ${HOME}/opt{include,lib} and setting this in my .bashrc:

export LD_LIBRARY_PATH="${HOME}/opt/lib"

I get my desired result:

Oper Sys : Linux 3.2.0-4-amd64
Platform : CPython 3.4.2
SQLite   : 3.8.6

Notice the SQLite version changes from 3.7.13 to 3.8.6

jftuga
  • 1,913
  • 5
  • 26
  • 49
  • hi, I followed your method here by doing `export LD_LIBRARY_PATH="/usr/local/opt"` in my `~/.bash_profile`, where `/usr/local/opt` is the directory that contains all the symlinks to homebrew installed libraries including `sqlite3`. However, after restart my bash, it still gives me the system-wide version of `sqlite3` in Python. Any suggestion? – skyork Mar 20 '15 at 23:16
  • Try using the method in the other answer, by @tzot. – jftuga Mar 21 '15 at 16:25
  • 1
    Worked for me, but note for others: Note the difference between `sqlite3.sqlite_version` (refers to SQLite library) and `sqlite3.version` (refers to the python module version that imports sqlite3, I suppose). – Jonathan Komar Jun 15 '18 at 11:03
0

Hi for me helped this:

cd /tmp
wget https://www.sqlite.org/2019/sqlite-autoconf-3280000.tar.gz
tar xvf sqlite-autoconf-3280000.tar.gz
mv /usr/bin/sqlite3 /usr/bin/sqlite3.7
cp /tmp/sqlite-autoconf-3280000/sqlite3 /usr/bin/sqlite3
cp /tmp/sqlite-autoconf-3280000/.libs/libsqlite3.so.0.8.6 /usr/lib64/libsqlite3.so.0.8.6
cp /tmp/sqlite-autoconf-3280000/.libs/libsqlite3.so.0 /usr/lib64/libsqlite3.so.0
DockCZ
  • 9
  • 1