Compile SQLite with SQLCipher on Windows

Let me Ask picture Let me Ask · Dec 4, 2010 · Viewed 9.7k times · Source

I am following this tutorial for compiling SQLite with SQLCipher on Windows. I am confused about pre-requisites for compilation. I found that I need to install following to compile it:

  1. OpenSSL
  2. MinGW
  3. ActiveState Perl
  4. TclTk / tclsh
  5. MSYS
  6. Visual Studio
  7. Cygwin

Among all above, I just have Visual Studio 2008 installed. I am working on Windows 7.

What are exact pre-requisites for compiling SQLite with SQLCipher on Windows?

Answer

snemarch picture snemarch · Dec 4, 2010

It seems that SQLCipher is distributed as a checkout of SQLite sources + modifications, judging by a quick look - and that being the multi-file version rather than the "amalgation". Thus, you need an environment capable of building SQLite sources, which means a bunch of unixy apps.

Personally, I'd do a diff between the SQLCipher source archives and the SQLite version it includes (which seems to be SQLite 3.7.2 for SQLCipher 1.8.2, judging by the VERSION file) - this should give an idea which modifications, if any, are done to the source SQLite files, as well as list files particular to SQLCipher.

To avoid hassles with building OpenSSL manually, you can grab prebuilt versions, which rids you of the Perl dependencies (iirc OpenSSL builds fine with Visual C++, so MingW shouldn't be a dependency).

If the SQLCipher author hasn't purposefully made the job of separating his specific code parts from SQLite tricky (which he might have, to cash in some money from selling win32 binaries), you'd be able to take his changes and combine with a SQLite amalgation version and prebuilt OpenSSL binaries, which should make for a really easy drop-in in a Visual Studio solution.

Of course it means you'll have to go through the extraction step if you want to upgrade to a newer version of SQLCipher, but it'd probably be worth it, unless you really want to install a cygwin development environment just to be able to build this single library.

Alternatively, you might be able to do the configure step of SQLCipher on a *u*x box (whether that being linux, *BSD or a Mac OS X shell), since the compile step shouldn't require all the funky tools.

UPDATE:

I checked out (version 3.7.2)[http://www.sqlite.org/src/info/42537b6056] of SQLite and ran a diff against the SQLCipher 1.1.8 distribution, and it seems like a pretty reasonable task to extract the modified portions:

Makefile.in - references added for the new crypto files.
tool/mksqlite3c.tcl: references added for the new crypto files.
src/pragma.c - one added block, marked /** BEGIN_CRYPTO **/
src/pager.c - one added block, marked /** BEGIN_CRYPTO **/
src/crypto.h - new file.
src/crypto.c - new file.

Also, it seems pretty overkill to take a dependency on OpenSSL just to get AES crypto support - building something new based on SQLCipher to use a dedicated (and much smaller) AES package would be nicer.