How to compile SQLCipher on Win64

Requirements

1. Install Visual Studio 2013

Install Visual Studio 2013 using the instructions here.

Only follow the instructions for that one page, not the rest of the guide it is part of.

2. Install ActiveTcl 8.5

Install ActiveTcl 8.5 using the instructions here.

3. Install OpenSSL

Install OpenSSL using the instructions here.

Only follow the instructions for that one page, not the rest of the guide it is part of.

4. Clone the SQLCipher repository

Launch GitHub Desktop, then click the + sign in the upper left corner:

xyz

Then click the “Clone” tab.

Assuming you have forked the “sqlcipher” repository already, it should be in the list. If it is not then go to https://github.com/sqlcipher/sqlcipher and Fork the repository first.

Select it, then click “Clone sqlcipher“:

Clone SQLCipher repo

Choose the C:\git_repos directory for cloning into:

Clone SQLCipher repo

Clone SQLCipher repo

5. Edit Makefile.msc

Open the SQLCipher source code folder:

Open SQLCipher source code folder

Edit the file C:\git_repos\sqlcipher\Makefile.msc using a text editor:

Edit Makefile.msc

Edit Makefile.msc

Values to be changed

  • SQLITE3DLL - Should be changed to sqlcipher.dll

Edit Makefile.msc

  • SQLITE3LIB - Should be changed to sqlcipher.lib

Edit Makefile.msc

  • SQLITE3EXE - Should be changed to sqlcipher.exe

Edit Makefile.msc

  • SQLITE3EXEPDB - Should be changed to /pdb:sqlciphersh.pdb

Edit Makefile.msc

  • -DSQLITE_TEMP_STORE - Change it from 1 to 2

Edit Makefile.msc

  • -DSQLITE_HAS_CODEC - Add this value to the TCC and RCC variables

Edit Makefile.msc

  • -IC:\dev\OpenSSL-Win64\include - Add this value to TCC and RCC too

Edit Makefile.msc

  • /LIBPATH:C:\dev\OpenSSL-Win64\lib /LIBPATH:C:\dev\OpenSSL-Win64\lib\VC - Add to the LTLIBPATHS variable
  • capi.lib padlock.lib libcrypto.lib libssl.lib - Add to the LTLIBS variable
  • Note - These filenames are just the list of files from C:\dev\OpenSSL-Win64\lib. If you have different files in your directory, use your filenames instead.

Edit Makefile.msc

  • Do a case sensitive search-n-replace, changing sqlite3.def to sqlcipher.def (you should find 6 instances)

[no screenshots done yet :wink:]

6. Compile SQLCipher

Launch the “VS2013 x64 Native Tools Command Prompt”.

It’s accessed through the “Visual Studio Tools” item in the Win 8.1 menu structure.

Win 8.1 menu structure screenshot

xyz

xyz

Change to the C:\git_repos\sqlcipher directory:

Compile SQLCipher

Then run this command to compile SQLCipher:

  1. nmake /f Makefile.msc

Compile SQLCipher

Compile SQLCipher

It should run for about a minute or so, and you’ll see various other commands running in the command prompt window.

It should finish without error, looking something like this:

Compile SQLCipher

If so, the process is now complete, with SQLCipher successfully compiled. 😋

7. Compile SQLCipher into DB4S

[This step still needs to be written up properly.]

With Qt Creator, add “CONFIG+=sqlcipher” to the qmake line, like this:

Add sqlcipher qmake option

If using MSVC 2013 as the IDE instead of Qt Creator, add “-Dsqlcipher=1” to the cmake command for generating the solution file. Like this:

  1. cmake -G "Visual Studio 12 2013 Win64" -Wno-dev -Dsqlcipher=1