Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compile SQLite with SQLCipher on Windows

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?

like image 548
Let me Ask Avatar asked Feb 26 '23 16:02

Let me Ask


2 Answers

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.

like image 109
snemarch Avatar answered Mar 08 '23 13:03

snemarch


The minimal setup you need to compile SQLCipher on windows is:

  1. OpenSSL, either in source or binary
  2. forms Perl - Optional, only required if you build OpenSSL
  3. MinGW / MSYS - required to configure SQLCipher
  4. Tcl - required by the SQLite build system to build the amalgamation code
  5. Visual Studio - to build your project

Using the steps in the thread, you can create the DLLs directly or generate an amalgamation to include in your project.

If you want to save all those steps and time, for a small charge you can also get precompiled SQLCipher windows binaries from the website at http://sqlcipher.net/downloads. These binary sales are mutually beneficial since they can help you get working more quickly, and they help support the project.

like image 29
Stephen Lombardo Avatar answered Mar 08 '23 12:03

Stephen Lombardo