Introduction

This introduction assumes that you have already downloaded SQLCipher to your computer.

Building from Source

Basic instructions for building from source are available in the README. Building SQLCipher is almost the same as compiling a regular version of SQLite with a few additional requirements. You must:

  1. define SQLITE_HAS_CODEC
  2. define SQLITE_TEMP_STORE=2 or SQLITE_TEMP_STORE=3 (or use configure’s –with-tempstore=yes option)
  3. define SQLITE_EXTRA_INIT=sqlcipher_extra_init and SQLITE_EXTRA_SHUTDOWN=sqlcipher_extra_shutdown
  4. define SQLITE_THREADSAFE to 1 or 2 (enabled automatically by configure)
  5. define HAVE_STDINT_H (if building outside of the ./configure flow and unit64_t is not available without stdint.h)
  6. compile and link with a supported cryptographic provider (OpenSSL, LibTomCrypt, CommonCrypto/Security.framework, or NSS)

The following examples demonstrate use of OpenSSL, which is a readily available provider on most Unix-like systems. Note that, in this example, --with-tempstore=yes is setting SQLITE_TEMP_STORE=2 for the build, and SQLITE_THREADSAFE has a default value of 1.

$ ./configure --with-tempstore=yes CFLAGS="-DSQLITE_HAS_CODEC -DSQLITE_EXTRA_INIT=sqlcipher_extra_init -DSQLITE_EXTRA_SHUTDOWN=sqlcipher_extra_shutdown" LDFLAGS="-lcrypto" 

$ make

While SQLCipher Community Edition is free for use, this process can be both difficult and time consuming, so we make a variety of pre-built Commercial Editional packages available for sale.