Compiling the latest sqlite3 on a Linux Ubuntu server

Introduction

We want to use the latest version of the sqlite(3.38.0 at the time of writing) but we also want, for example, python and php to use the latest sqlite shared library as well. Since the linux ubuntu distribution doesn't keep up with the latest releases from sqlite, we'll have to compile from source and install the shared libraries in the system.

Downloading the source code

wget https://www.sqlite.org/2022/sqlite-autoconf-3380000.tar.gz
tar xvf sqlite-autoconf-3380000.tar.gz

Compiling and installing sqlite3

sudo apt-get install build-essential
cd sqlite-autoconf-3380000/
./configure
make
sudo make install
cat /etc/ld.so.conf.d/libc.conf

───────┬────────────────────────────────────────────────────────
       │ File: /etc/ld.so.conf.d/libc.conf
───────┼────────────────────────────────────────────────────────
    1  │ # libc default configuration
    2  │ /usr/local/lib
───────┴────────────────────────────────────────────────────────
sudo ldconfig

Verifying that our system is using the latest sqlite3

Finally, if everything went well, we should be using the latest sqlite3 system-wide.

sqlite3 --version

# example output
3.38.0 2022-02-22 18:58:40 40fa792d359f84c3b9e9d6623743e1a59826274e221df1bde8f47086968a1bab
    python3 -c "import sqlite3; print(sqlite3.sqlite_version)"

    # example output
    3.38.0
php8.1 --ri sqlite3

# example output
sqlite3

SQLite3 support => enabled
SQLite Library => 3.38.0

Directive => Local Value => Master Value
sqlite3.extension_dir => no value => no value
sqlite3.defensive => On => On